// OPERATION 1 // void update1( int i , int b , int c , int s , int e ,int v){ if(i>=size)return; propogate( i , b , c ); if ( ( e < b) || ( c < s) ) { return ; } if ( ( s <= b) && ( c <= e) ) { tree[i]=(tree[i]*v)%mod ; if ( b != c) { propogate(2*i,b,(b+c)/2); propogate(2*i+1,((b+c)/2)+1,c); lazy[ 2*i + 1].y = 1 ; lazy[ 2*i].y = 1 ; lazy[ 2*i].a1 = (lazy[2*i].a1* (ll)v)%mod ; lazy[ 2*i+1].a1 = (lazy[2*i+1].a1* (ll)v)%mod ; propogate(2*i,b,(b+c)/2); propogate(2*i+1,((b+c)/2)+1,c); //update1( 2*i , b , (b + c )/ 2 , s , e , v ); //update1( 2*i + 1 , ( (b + c )/ 2 + 1 ) , c , s , e , v ); } return ; } update1( 2*i , b , (b + c )/ 2 , s , e , v ); update1( 2*i + 1 , ( (b + c )/ 2 + 1 ) , c , s , e , v ); tree[i] = (tree[2*i] + tree[2*i + 1])%mod; }
void update2(int ly, int uy, int lx, int ux, int v) { for(;ly<=uy;ly=pai(ly),uy=pai(uy)) { if (ly&1) update1(ly++, lx, ux, v); if (!(uy&1)) update1(uy--, lx, ux, v); } }
/* update gains after a move */ void update_gains(selected_cell_t scell[], cells_t cells[], nets_t nets[], corn_t cnets[], corn_t ncells[], cells_info_t cells_info[], allele tchrom[]) { int net_ptr = cells[scell[0].mov_cell_no].netlist; int mov_cell_no = scell[0].mov_cell_no; int from_part = scell[0].from_part; int to_part = scell[0].to_part; /* for each neighor net */ for (int i = 0; i < cells[mov_cell_no].cno_nets; i++) { int net_no = cnets[net_ptr + i].corn_no; int net_weight = nets[net_no].nweight; int cell_ptr = nets[net_no].celllist; /* do operations before the move */ if (nets[net_no].npartdeg[from_part] == nets[net_no].nno_cells) { update1(False, from_part, mov_cell_no, cell_ptr, net_no, net_weight, nets, ncells, cells_info); } else if (nets[net_no].npartdeg[from_part] == (nets[net_no].nno_cells - 1)) { update2(False, from_part, mov_cell_no, cell_ptr, net_no, net_weight, nets, ncells, cells_info, tchrom); } /* else */ /* update net info */ nets[net_no].npartdeg[from_part]--; nets[net_no].npartdeg[to_part]++; /* do operations after the move */ if (nets[net_no].npartdeg[to_part] == nets[net_no].nno_cells) { update1(True, to_part, mov_cell_no, cell_ptr, net_no, net_weight, nets, ncells, cells_info); } else if (nets[net_no].npartdeg[to_part] == (nets[net_no].nno_cells - 1)) { update2(True, to_part, mov_cell_no, cell_ptr, net_no, net_weight, nets, ncells, cells_info, tchrom); } /* else */ } /* for i */ } /* update_gains */
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { setGeometry(0,0,400,400); ui->setupUi(this); //QPalette lcdpalette;// = new QPalette; //lcdpalette.setColor(); //lcdpalette.setColor(QPalette::Background, Qt::red); //lcdpalette.setColor(QPalette::Base, QColor(0, 0, 0)); //lcdpalette.setColor(QPalette::Text, QColor(0, 255, 0)); ui->label_22->setPalette(Qt::red); //ui->lcd_pulse->setPalette(lcdpalette); //ui->lcd_angle->setPalette(Qt::red); ui->lcd_pulse->display(0); ui->lcd_angle->display(0); ui->results_box->setGeometry(10,290,471,171); ui->measures_box->setGeometry(10,90,601,191); ui->measure_box->setGeometry(10,90,591,381); ui->pushButton_4->hide(); ui->number_label->hide(); ui->lineEdit->hide(); ui->pushButton_5->hide(); ui->lcd_cur_angle->hide(); timer1 = new QTimer(this); connect(timer1, SIGNAL(timeout()), this, SLOT(update1())); timer2 = new QTimer(this); connect(timer2, SIGNAL(timeout()), this, SLOT(update2())); }
int main(){ ll r; int t , n , h , q , i , s , e , type,v; scanf("%d%d" , &n , &q); h = (ceil)( log2(n)); size = 1<<( h + 1); for ( i = 1 ; i < size ; i++) { tree[i] = 0 ; clear(i); } for ( i = 0 ; i < n ; i++) { scanf("%d",&a[i]); } create( 1 , 0 , n - 1); while(q--) { scanf("%d" ,&type); if ( type == 2) { scanf("%d%d%d" , &s , &e,&v); s--; e--; v%=mod; update1( 1 , 0 , n-1 ,s , e,v); } else if ( type == 1) { scanf("%d%d%d" , &s , &e , &v); s--; e--; v%=mod; update2( 1 , 0 , n - 1 , s , e , v); } else if ( type == 3) { scanf("%d%d%d" , &s , &e , &v); s--; e--; v%=mod; update3( 1 , 0 , n - 1 , s , e , v); } else { scanf("%d%d" , &s , &e); s--; e--; r = query( 1 , 0 , n-1 ,s , e ); printf("%lld" , r); printf("\n"); } } return 0 ; }
void ball_main() { printf("flag==%d\n",flag); if(flag==1) { ball1(); ball2(); update1(); } else { ball3(); ball4(); ball5(); ball6(); update2(); } }
int Enemy::update() { if (hittimer > 0) { hittimer--; if (hittimer == 0) { state = 0; } } if (parent->player != NULL) { double delta = x - parent->player->getx(); if (fabs (delta) > 1000) return 0; // out of range, don't update. } phase = (phase + 1) % period; SpriteEx::update(); switch (enemyType) { case 0: update1(); break; case 1: update2(); break; case 2: update3(); break; case 3: update4(); break; } return 0; }