結果
問題 |
No.491 10^9+1と回文
|
ユーザー |
|
提出日時 | 2017-03-10 22:55:34 |
言語 | C90 (gcc 12.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 453 bytes |
コンパイル時間 | 289 ms |
コンパイル使用メモリ | 21,632 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-24 08:28:38 |
合計ジャッジ時間 | 2,413 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | WA * 103 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:12:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | scanf("%lld",&n); | ^~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h> const long long p=1000000001; long long powten(long long n){ if(n<=0) return 1; return powten(n-1)*10; } int main(int argc, char const *argv[]){ long long n,a,b,c; scanf("%lld",&n); a=n/p; b=0; c=0; while(a>0){ b++; a/=10; } for(a=1;a<b;a++){ c+=9*powten((a+1)/2-1); } while(n>0){ c+=(n/p/powten(b-1)-1)*powten((b+1)/2-1); n-=n/p/powten(b)*(powten(b-1)+1); b-=2; n/=10; } printf("%lld\n",c); return 0; }