結果
問題 |
No.428 小数から逃げる夢
|
ユーザー |
![]() |
提出日時 | 2016-10-04 20:45:37 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 621 bytes |
コンパイル時間 | 136 ms |
コンパイル使用メモリ | 23,808 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-21 16:49:05 |
合計ジャッジ時間 | 2,747 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 78 WA * 22 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:9:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | scanf("%d",&n); | ~~~~~^~~~~~~~~
ソースコード
#include<cstdio> #include<cstring> char s[] = "0.1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991"; char ans[200]; int main(){ int n; scanf("%d",&n); int res = 0; int p = 0; for(int i=2;i<192;i++){ res = res+n*(s[i]-48); sprintf(ans+p,"%d",res/10000); p = strlen(ans); res%=10000; res*=10; } sprintf(ans+p,"%d",res); if(n<=8) printf("0"); else if(n<=81) printf("%c",ans[3]); else printf("%c%c",ans[2],ans[3]); printf(".%s\n",ans+4); }