結果
問題 | No.491 10^9+1と回文 |
ユーザー |
![]() |
提出日時 | 2017-03-15 21:22:50 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 1,000 ms |
コード長 | 578 bytes |
コンパイル時間 | 297 ms |
コンパイル使用メモリ | 23,424 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-01 08:38:05 |
合計ジャッジ時間 | 2,943 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 103 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:36:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 36 | scanf("%lld",&n); | ~~~~~^~~~~~~~~~~
ソースコード
#include<cstdio>typedef long long ll;ll palindrome1(ll x){int cnt = 0;ll y = x;ll z = 0;while(x>0){z *= 10;z += x % 10;x /= 10;cnt++;}for(int i=0;i<cnt;i++) y *= 10;return y + z;}ll palindrome2(ll x){int cnt = 0;ll y = x;ll z = 0;while(x>0){z *= 10;z += x % 10;x /= 10;cnt++;}y /= 10;for(int i=0;i<cnt;i++) y *= 10;return y + z;}int main(){ll n;int ans = 0;scanf("%lld",&n);n /= 1000000001;for(int i=1;i<100000;i++){if(palindrome1(i)<=n) ans++;if(palindrome2(i)<=n) ans++;}printf("%d\n",ans);}