Submission #64053
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | #include<bits/stdc++.h> using namespace std; template < class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true ); } template < class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true ); } typedef long long ll; typedef vector< int > vint; typedef pair< int , int > pint; typedef vector< long long > vlong; typedef vector<string> vstring; #define _GLIBCXX_DEBUG #define vpush(a,x) a.push_back(x); #define rep(i, n) REP(i, 0, n) #define all(v) v.begin(), v.end() #define REP(i, x, n) for(int i = x; i < n; i++) const int INF = 1 << 30; const int dx[] = {1,0,-1,0,1,1,-1,-1}; const int dy[] = {0,-1,0,1,1,-1,-1,1}; #define stp(x) setprecision(x) int main(){ cin.tie(nullptr); ios::sync_with_stdio( false ); int n; cin>>n; vector< int > dp(n+1,0); dp[n]=1; for ( int i=n;i>=0;i--){ if (dp[i]!=0){ for ( int j=i-1;j>=i-100;j--){ int wa=0,tmp=j; while (tmp!=0){ wa+=tmp%10; tmp/=10; } if (wa+j==i){ dp[j]=1; } } } } int ans=0; rep(i,n+1){ ans+=dp[i]; } cout<<ans<< '\n' ; return (0); } |
ステータス
項目 | データ |
---|---|
問題 | 1267 - 桁和 (Digit Sum) |
ユーザー名 | ei1918 |
投稿日時 | 2020-09-15 22:27:52 |
言語 | C++14 |
状態 | Accepted |
得点 | 100 |
ソースコード長 | 1180 Byte |
最大実行時間 | 514 ms |
最大メモリ使用量 | 4656 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 100 / 100 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
01-01.txt | AC | 23 ms | 3932 KB |
1
|
01-02.txt | AC | 82 ms | 3244 KB |
1
|
01-03.txt | AC | 24 ms | 1220 KB |
1
|
01-04.txt | AC | 18 ms | 2376 KB |
1
|
01-05.txt | AC | 21 ms | 4388 KB |
1
|
01-06.txt | AC | 27 ms | 2812 KB |
1
|
01-07.txt | AC | 19 ms | 4256 KB |
1
|
01-08.txt | AC | 23 ms | 2956 KB |
1
|
01-09.txt | AC | 23 ms | 4300 KB |
1
|
01-10.txt | AC | 20 ms | 436 KB |
1
|
01-11.txt | AC | 22 ms | 520 KB |
1
|
01-12.txt | AC | 19 ms | 608 KB |
1
|
01-13.txt | AC | 24 ms | 688 KB |
1
|
01-14.txt | AC | 514 ms | 4612 KB |
1
|
01-15.txt | AC | 184 ms | 4624 KB |
1
|
01-16.txt | AC | 103 ms | 4636 KB |
1
|
01-17.txt | AC | 26 ms | 4656 KB |
1
|
sample-01.txt | AC | 20 ms | 572 KB |
1
|
sample-02.txt | AC | 28 ms | 656 KB |
1
|
sample-03.txt | AC | 20 ms | 484 KB |
1
|