修改过----AtCoder Beginner Contest 190 DStaircase Sequences(唯一分解求因子数)
生活随笔
收集整理的這篇文章主要介紹了
修改过----AtCoder Beginner Contest 190 DStaircase Sequences(唯一分解求因子数)
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
D Staircase Sequences
題意:
給你一個(gè)和sum。問(wèn)你是否可以拆成公差為1的等差數(shù)列。
求:
最多可以拆成多少個(gè)。
思路:
反思:
2020-1-31發(fā)現(xiàn),猜得不嚴(yán)謹(jǐn)。有點(diǎn)對(duì)不起讀者,所以特地來(lái)補(bǔ)充完整。
題目要求:
過(guò)程
AC
/* 皮卡丘沖鴨! へ /|/\7 ∠_// │ / /│ Z _,< / /`ヽ│ ヽ / 〉Y ` / /イ● 、 ● ??〈 /() へ | \〈>ー 、_ ィ │ /// へ / ノ<| \\ヽ_ノ (_/ │//7 |/>―r ̄ ̄`ー―_ */ #include <iostream> #include <bits/stdc++.h> #define For(i,x,y) for(int i=(x); i<=(y); i++) #define fori(i,x,y) for(int i=(x); i<(y); i++) #define rep(i,y,x) for(int i=(y); i>=(x); i--) #define mst(x,a) memset(x,a,sizeof(x)) #define pb push_back #define sz(a) (int)a.size() #define mp make_pair #define fi first #define se second #define debug(a) cout << #a << ": " << a << endl using namespace std; typedef long long ll; typedef pair<int,int>pa; typedef pair<ll,ll>pai; const int N = 2e5+10; const int M = 1e5; int main() {ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);ll x;cin>>x;vector<int>prime, prime_num;ll ans = 1;for(int i = 2; i <= x/i; i ++ ){if(x%i==0){prime.pb(i);ll cnt = 0;while(x%i==0)x/=i,cnt++;// debug(i);// debug(cnt);// if(i!=2)ans+=cnt*2;if(i!=2) ans*=(cnt+1);}}if(x>2)ans*=2;// ans+=2;cout<<ans*2<<endl;return 0; }總結(jié)
以上是生活随笔為你收集整理的修改过----AtCoder Beginner Contest 190 DStaircase Sequences(唯一分解求因子数)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Python环境下数据处理常用命令
- 下一篇: .net mvc ef 视图未定义主键问