hdu--4902--線段樹

題意 前面一段廢話= =

這題 最有意思的應該是出題人 是clj

這題的時限放的太寬了 給了15s 我也是醉了

區間更新。

  1 #include <iostream>
  2 #include <algorithm>
  3 using namespace std;
  4 
  5 const int size = 200010;
  6 int a[size];
  7 struct data
  8 {
  9      int L , R , maxVar;
 10      bool flag;
 11 }tree[size<<2];
 12 
 13 int gcd( int x , int y )
 14 {
 15      return x % y == 0 ? y : gcd( y , x%y );
 16 }
 17 
 18 void pushDown( int rt )
 19 {
 20     tree[rt<<1].maxVar = tree[rt<<1|1].maxVar = tree[rt].maxVar;
 21     tree[rt<<1].flag = tree[rt<<1|1].flag = true;
 22     tree[rt].flag = false;
 23 }
 24 
 25 void pushUp( int rt )
 26 {
 27     tree[rt].maxVar = max( tree[rt<<1].maxVar , tree[rt<<1|1].maxVar );
 28 }
 29 
 30 void build( int rt , int L , int R )
 31 {
 32     int M = ( L + R ) >> 1;
 33     tree[rt].L = L , tree[rt].R = R;
 34     tree[rt].flag = false;
 35     if( L==R )
 36     {
 37         tree[rt].maxVar = a[L];
 38         tree[rt].flag = true;
 39         return ;
 40     }
 41     build( rt<<1 , L , M );
 42     build( rt<<1|1 , M+1 , R );
 43     pushUp( rt );
 44 }
 45 
 46 void update( int rt , int L , int R , int x , int op )
 47 {
 48     int M = ( tree[rt].L + tree[rt].R ) >> 1;
 49     if( tree[rt].L == L && tree[rt].R == R )
 50     {
 51         if( op==1 )
 52         {
 53             tree[rt].maxVar = x;
 54             tree[rt].flag = true;
 55             return;
 56         }
 57         else
 58         {
 59             if( tree[rt].maxVar<=x )
 60                 return ;
 61             if( tree[rt].flag && tree[rt].maxVar>x )
 62             {
 63                 tree[rt].maxVar = gcd( tree[rt].maxVar , x );
 64                 return;
 65             }
 66         }
 67     }
 68     if( tree[rt].flag )
 69     {
 70         pushDown( rt );
 71     }
 72     if( R<=M )
 73     {
 74         update( rt<<1 , L , R , x , op );
 75     }
 76     else if( L>=M+1 )
 77     {
 78         update( rt<<1|1 , L , R , x , op );
 79     }
 80     else
 81     {
 82         update( rt<<1 , L , M , x , op );
 83         update( rt<<1|1 , M+1 , R , x , op );
 84     }
 85     pushUp( rt );
 86 }
 87 
 88 void solve( int rt , int L , int R )
 89 {
 90     int M = ( tree[rt].L + tree[rt].R ) >> 1;
 91     if( L == R )
 92     {
 93         cout << tree[rt].maxVar << " ";
 94         return ;
 95     }
 96     if( tree[rt].flag )
 97     {
 98         pushDown( rt );
 99     }
100     solve( rt<<1 , L , M );
101     solve( rt<<1|1 , M+1 , R );
102 }
103 
104 int main()
105 {
106      cin.sync_with_stdio(false);
107      int t , n , m , op , L , R , x;
108      cin >> t;
109      while( t-- )
110      {
111           cin >> n;
112           for( int i = 1 ; i<=n ; i++ )
113                cin >> a[i];
114           build( 1 , 1 , n );
115           cin >> m;
116           while( m-- )
117           {
118                   cin >> op >> L >> R >> x;
119                   update( 1 , L , R , x , op );
120           }
121           solve( 1 , 1 , n );
122           cout << endl;
123      }
124      return 0;
125 }
View Code

?

明天 是個特殊的日子 。。

?

轉載于:https://www.cnblogs.com/radical/p/4162103.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/376408.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/376408.shtml
英文地址,請注明出處:http://en.pswp.cn/news/376408.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

(五) 面向對象類設計原則

1. 開閉原則&#xff08;the Open Closed Principle OCP&#xff09; 一個模塊在擴展性方面應該是開放的而在更改性方面應該是封閉的。因此在進行面向對象設計時要盡量考慮接口封裝機制、抽象機制和多態技術。該原則同樣適合于非面向對象設計的方法&#xff0c;是軟件工程 設計…

160 - 30 cracking4all.1

環境 Windows XP sp3 工具 exeinfope ollydbg 查殼 無殼的VB程序 測試 這個serial藏得比較里面&#xff0c;多點幾下才能看到 字符串搜索&#xff1a; 00403338 . 50 push eax ; /var18 00403339 . 51 …

java2s.com

http://www.java2s.com/Code/JavaAPI/CatalogJavaAPI.htm轉載于:https://www.cnblogs.com/reborn2012/p/3326445.html

MVC5 + EF6 入門完整教程

MVC5 EF6 入門完整教程 原文:MVC5 EF6 入門完整教程第0課 從0開始 ASP.NET MVC開發模式和傳統的WebForm開發模式相比&#xff0c;增加了很多"約定"。 直接講這些 "約定" 會讓人困惑&#xff0c;而且東西太多容易忘記。 和微軟官方教程不同&#xff0c…

160 - 31 cracking4all.2

環境 Windows xp sp3 工具 exeinfope ollydbg 查殼 無殼VB程序 測試 輸入1234567 OD載入字符串搜素&#xff0c;往上翻就看到這里&#xff0c;我截取部分片段&#xff1a; 00402C26 . 8D55 98 lea edx,dword ptr ss:[ebp-0x68] ; 取serial長度…

stm32的DFU使用方法

stm32的dfu看上去是個很高級的東西&#xff0c;似乎可以通過USB給內部flash、外部spi flash、外部nor等東西刷寫數據、把數據讀出來&#xff0c;但是用了一下感覺確實有點麻煩。 先不管原理是怎樣的&#xff0c;使用方法是這樣&#xff1a; 1、先下載這個Dfuse&#xff0c;然后…

160 - 32 genocide1

環境 Windows xp sp3 工具 upx exeinfope ollydbg 查殼 發現是upx殼&#xff0c;手脫的話會不干凈&#xff0c;影響OD分析。 所以就直接用 upx -d 脫了 手脫&#xff1a; upx -d: 用upx -d 脫的版本進行分析。 第一次運行時顯示這個&#xff1a; 缺少Reg.dat…

vector function trmplate

/*vectorfunction templateprogrammer:qpz */ #include <iostream> #include <vector> #define MAX 10 using namespace std; class Myclass{ private:vector <int> vel;//可均分的動態數組 public:void Add(int x){vel.push_back(x);}void print(); }; void…

軟件工程個人項目11061180王宇杰

&#xff08;1&#xff09;我完全不知道要花費多少時間&#xff0c;因為從來沒有進行過類似的項目&#xff0c;涉及的很多問題我以前也根本不會。簡單的估計一下&#xff0c;這至少是15小時的工作量。 &#xff08;2&#xff09;前期的準備工作很耗時間&#xff0c;因為一開始根…

160 - 33 Cruehead.1

環境 windows xp sp3 工具 exeinfo pe ollydbg 查殼 無殼的匯編程序&#xff08;OD載入的出來的&#xff09; 測試 當name輸入為數字時&#xff0c;會彈出兩次錯誤框。 OD載入搜字符串&#xff0c;發現有兩個地方&#xff1a; 0040134D /$ 6A 30 push 0x…

mac osx 10.10 pip 安裝問題

在mac osx 升級到 10.10(Yosemite)以后&#xff0c;用pip以及easy_install 安裝python包的時候&#xff0c;如果包需要編譯&#xff0c;就會編譯失敗&#xff0c;錯誤如下&#xff1a; build/temp.macosx-10.10-x86_64-2.7/greenlet.o -o build/lib.macosx-10.10-x86_64-2.7/gr…

英文系統上網頁內容亂碼的解決

今天隨便寫了一段html 代碼示例&#xff0c;代碼如下&#xff1a; <html lang"zh-cn"> <head> </head> <body> <h1>HTML 教程目錄</h1> <ul> <li><a href"#C1">第一章</a></li> <li…

160 - 34 Cruehead.3

環境 windows xp sp3 工具 1.exeinfo pe 2.ollydbg 3.WinHex 查殼 和上一個一樣&#xff0c;OD載入判斷出 測試 運行后發現是沒有任何提示&#xff0c;而且沒有輸入serial的窗口&#xff0c;通過任務管理器可以看出程序的名稱寫有“Uncracked”&#xff0c;可以猜測…

sed awk tr等文本處理命令

指定行范圍替換&#xff1a; sed -i "520,950s/\(.*\)\(HOST_CMD_.*\)\(,\)/\1{ \2, \"\2\" },/g" hostCmdMacro.h linux shell sed命令與轉義字符 A“2013/06/09“ sed “s#hello#$A#" sed 指定行范圍匹配 刪除文本中的重復行(sortuniq/awk/sed) 263…

160 - 35 cupofcoffe.1

環境 Windows xp sp3 工具 1.exeinfo PE 2.ollydbg 查殼 OD載入后可以看出是VB程序 測試 輸入&#xff1a;12345678 顯示的內容發生了改變&#xff0c;也不影響查找字符串。 004FEC14 > \8B4D E8 mov ecx,dword ptr ss:[ebp-0x18] 004FEC17 . 51 …

centos7 安裝mysql

http://my.oschina.net/u/919612/blog/310533 測試可用 隨后又想到了&#xff0c;做個iso鏡像&#xff0c;然后掛載在CDrom上&#xff0c;然后安裝JDK成功&#xff0c;但是mysql安裝失敗&#xff0c;可能由于只從官網上下載了server&#xff0c;而沒有解決依賴關系。 最后&…

ecshop后臺增加模板頁的方法

CShop的動態模板機制是一個非常靈活的系統,管理員可以在后臺根據自己的要求調整模板模塊的顯示位置。本文詳細講解了如何修改ECSHOP內部結構使得用戶可以添加自己的模板頁從而方便靈活的使用系統自帶的模板系統和廣告位系統。 如下圖所示 可以看到ECShop支持設置的模板一共如上…

160 - 36 cupofcoffe.2

環境 Winows xp sp3 工具 1.exeinfo PE 2.ollydbg 查殼 OD載入后看出是VB程序 測試 輸入&#xff1a;12345678 繼續OD搜字符串&#xff1a; 00521688 . 68 60054500 push cupofcof.00450560 ; UNICODE ".........." 0052168D …

使用VS2010 + VirtualDDK 調試驅動

總的說來比 WINDBG要簡單的多 可以看到詳細的調試內容 但是好像不知道怎么弄成一般的工程 待定今天玩了一下 感覺還是有點麻煩 網站&#xff1a; http://techird.blog.163.com/blog/static/1215640362011112385241568/ 轉載于:https://www.cnblogs.com/zcc1414/p/3982457.html…

160 - 37 CyberBlade.1

環境 Windows xp sp3 工具 1.exeinfo PE 2.ollydbg 查殼 OD載入是VB程序。 測試 OD載入直接搜字符串。 這個是當輸入為空時會彈出消息框告訴你要輸入9個字符。 0040E005 > \8B4D E4 mov ecx,dword ptr ss:[ebp-0x1C] 0040E008 . 51 push…