結果
| 問題 |
No.491 10^9+1と回文
|
| コンテスト | |
| ユーザー |
goodbaton
|
| 提出日時 | 2017-05-30 23:05:48 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 81 ms / 1,000 ms |
| コード長 | 1,221 bytes |
| コンパイル時間 | 774 ms |
| コンパイル使用メモリ | 87,096 KB |
| 実行使用メモリ | 8,832 KB |
| 最終ジャッジ日時 | 2024-10-01 08:44:21 |
| 合計ジャッジ時間 | 4,506 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 103 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:33:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
33 | scanf("%lld",&n);
| ~~~~~^~~~~~~~~~~
ソースコード
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <cassert>
typedef long long ll;
using namespace std;
#define debug(x) cerr << #x << " = " << (x) << endl;
#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010
int main(){
ll n;
set<ll> mm;
scanf("%lld",&n);
int m = n/1000000000;
int ans = 0;
for(int i=0;i<=m;i++){
int p = i;
char s1[20],s1_r[20],s2[20];
sprintf(s1_r,"%d",p);
reverse(s1_r,s1_r+strlen(s1_r));
sprintf(s1,"%d%s",p,s1_r);
sprintf(s2,"%d%s",p/10,s1_r);
ll q1 = atoll(s1);
ll q2 = atoll(s2);
//debug(q1);
//debug(q2);
if(q1 < 1000000000LL && q1 + q1*1000000000 <= n && mm.find(q1) == mm.end()){
mm.insert(q1);
ans++;
}
if(q2 < 1000000000LL && q2 + q2*1000000000 <= n && mm.find(q2) == mm.end()){
mm.insert(q2);
ans++;
}
if(q1 >= 10000000000LL) break;
}
cout << ans-1 << endl;
return 0;
}
goodbaton