CodeFroces-- 514.div2.C-Sequence Transformation
題目連結 : 514.div2.C-Sequence Transformation
#include<bits/stdc++.h> using namespace std; #define maxn 1000011 int a[maxn]; int main(){ int n; cin>>n; int y=1,t=0; while(n>1){ int x=0,z; for(int j=2;j<=n;j++){ if(n/j>=x){ x=n/j; z=j; } } for(int j=1;j<=n;j++){ if(j%z!=0){ a[t++]=y; } } n/=z; y*=z; } a[t++]=y; for(int j=0;j<t;j++){ cout<<a[j]<<" "; } }
相關推薦
CodeFroces-- 514.div2.C-Sequence Transformation
題目連結 : 514.div2.C-Sequence Transformation #include<bits/stdc++.h> using namespace std; #define maxn 1000011 int a[maxn]; int main(){
Codeforces Round #514 (Div. 2) C. Sequence Transformation 思維構造
題意 給出一個1-n的集合 gcd 集合裡面的所有數 得到的 一個 數 然後自己選擇刪去一個數 要使得到的數 構成的數列 的字典序最大 思路: gcd所有數 那gcd得到的數肯定要小於陣列中最小的數 所以 剛開始
Codeforces Round #514 (Div. 2) C.Sequence Transformation(找規律)
題意:給定一個數字,找從1到n這n個數字的最大公約數,然後從這n個數字中去掉一個數字,使得去掉之後剩下的n-1個數字的最大公約數能比之前的大,每次都去掉一個數字,使得最大公約數能夠最快的上升。 思路:列出1到9的答案:1:1,2:12,3:113,4:1124,5:11124,6:111226,
Codeforces Round #514 (Div. 2)--C. Sequence Transformation
博主連結 題目連結 題意: 給你一個n,一共有數1~n,每次取出他們的GCD放入陣列中,並隨便刪除一個數,最後要求陣列的字典序最大。 題解: 先刪除奇數,在刪2^…次方的倍數(需要注意:比如刪2的倍數時,不能刪4的倍數,8的倍數…)並用變數記錄倒數第二輪刪的最
Codeforces Round #514 (Div. 2), problem: (C) Sequence Transformation
這個c題還挺有意思的,一開始實在是看不懂題,後來理解了,要字典序(誤)最大,就必須越快增加整個數列的gcd越好。 注意到這個數列是有序而且從1到n,那麼先假設n比較大,這個時候gcd是1,我們要刪掉最少的數讓gcd改變,最少刪掉多少呢? n範圍內,是2這個數的倍數的數
CF C. Sequence Transformation【規律】
題意:給你一個n 然後代表1到n的一個序列 然後說每次進行一種操作 序列當前所有數的gcd 然後把gcd結果加入一個答案陣列 然後此時可以刪除序列中的一個數 重複這種操作 直至序列沒有數 同時保證答案序列是字典序最大 前面的數越大越好 收穫:樣例
C Sequence Transformation (思維gcd)
C. Sequence Transformation time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard
#419(div2) C. Karen and Game
clu 更多 names code bits nod 矩陣 hang 是否 題意:給出一個n*m的矩陣,然後我們可以每一行-1,每一列-1,問是否可以全部變成0 思路:最開始的時候馬上就想到了無論怎樣,他每一行該減去的時候無論先後都要減去,那麽我每一行取一個最小值減去,然後
TopCoder SRM 717 Div2 C.DerangementsDiv2[數論][容斥原理][錯排]
long max math 需要 linker nal tex 排列 lin 題意:從1到n+m的數組中選m個數字且每個數字和在原數組中下標不同,求方案數。例如 n=1 m = 2 則存在{2,1},{2,3},{3,1} 題解:錯排問題模板 下面是使用容斥原理推導的過程
codeforces 1059C. Sequence Transformation【構造】
ati pro using 奇數 sed orm 思路 字典序 分享圖片 題目:戳這裏 題意:有1,2,3...n這n個數,求一次這些數的gcd,刪去一個數,直到剩下一個數為止。輸出這n個gcd的最大字典序。 解題思路:一開始的gcd肯定是1,要讓字典序最大,我們可以想到下
CF1059C Sequence Transformation 題解
let 如果 targe seq input 給定 wing using common 這幾天不知道寫點什麽,狀態也不太好,搬個題上來吧 題意:給定一個數n,設一個從1到n的序列,每次刪掉一個序列中的數,求按字典序最大化的GCD序列 做法:按2的倍數找,但是如果除
codeforces round 514div2C Sequence Transformation(思維+找規律)
題意 給出一個長度為 n n n的序列,初始序列為
[codeforces round#475 div2 ][C Alternating Sum ]
http://codeforces.com/contest/964/problem/C 題目大意:給出一個等比序列求和並且mod 1e9+9. 題目分析:等比數列的前n項和公式通過等公比錯位相減法可以得到是Sn=A1*(q^n-1)/(q-1).這裡注意q不能等於1. 坑點:而本題的q=(b/a)^k,
Codeforces Round #514 (Div. 2) CSequence Transformation
題目:給定1.。。n的數,每次取出一個數,然後計算剩下數中的最大公因數,這個最大公因數排成的序列得最大。woc,比賽時理解錯題意了,以為高位最大那就是最大了,沒想到他題目想表達的是,要最先出現最大數的為最大。太坑了。以後還有待做讀題訓練 思路:很好理解,不多講了。 #include<c
Codeforces Round #522 div2 C、E題解(DP)
題目連結: C. Playing Piano 題意: 給一個序列,讓你構造一個相等長度的序列,構造的序列中每個元素的取值範圍都為[1,5]。 構造要求: 1. 若原序列a[i]==a[i+1],那麼構造的序列b[i]!=b[i+1]; 2. 若原序列a[i]>a[i
Codeforces Round #513 div2 C D
C 題 給了一個數組 a ,陣列 b c[i][j] = a[i]*b[j] 要求一個面積最大並且和小於x的子矩陣 題目分析 我們可以知道 每個子矩陣中的和 應該是某一段 a[i] 的和 * 某一個b
Sequence Transformation(CodeForces 1059C)
Description Let's call the following process a transformation of a sequence of length nn. If the sequence is empty, the process ends. Ot
CodeForces Round #514 (div2)
A:Cashier 題意:問可以休息多少次。 程式碼: #include<bits/stdc++.h> using namespace std; #define Fopen freopen("_in.txt","r",stdin); freopen("_out.txt"
codeforces #262 DIV2 C題Present(二分+貪心)
這個題是用二分列舉最小值,然後判斷能否在規定的次數內使得所有的數都達到這個值。判斷的時候要用貪心的方法判斷,從左往右遍歷,這時候需要讓每次澆花的範圍儘量向右。所以當到達一個不得不澆花的地方時,要繼續
codeforces div2 C. Ehab and a 2-operation task
題目連結: http://codeforces.com/contest/1088/problem/C 題目大意,給你一個數組,陣列中的資料不超過1e5,讓你經過不超過n+1次的以下兩個操作,變為是嚴格遞增的陣列。 1,輸出1,j,x,表示對所有的1<=i<=j,arr[i]變