結果
問題 |
No.491 10^9+1と回文
|
ユーザー |
![]() |
提出日時 | 2017-03-10 22:44:46 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,291 bytes |
コンパイル時間 | 744 ms |
コンパイル使用メモリ | 89,736 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-24 07:58:55 |
合計ジャッジ時間 | 2,965 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 42 WA * 61 |
ソースコード
#include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <memory> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; #define sz size() #define pb push_back #define mp make_pair #define fi first #define se second #define all(c) (c).begin(), (c).end() #define rep(i,a,b) for(ll i=(a);i<(b);++i) #define per(i,a,b) for(ll i=(b-1);i>=(a);--i) #define clr(a, b) memset((a), (b) ,sizeof(a)) #define ctos(c) string(1,c) #define print(x) cout<<#x<<" = "<<x<<endl; #define MOD 1000000007 string ntos(long long n){ string s; stringstream ss; ss << n; ss >> s; return s; } long long ston(string s){ long long n; sscanf(s.c_str(), "%lld", &n); return n; } int main() { ll n; cin>>n; ll a = n/1000000000LL; if(a==0){ cout<<0<<endl; return 0; } string s = ntos(a); string ss; rep(i,0,s.sz){ ss += s[0]; } ll b = ston(ss); ll c = b*1000000000+b; if(n>=c){ cout << (s.sz-1)*9+(s[0]-'0') << endl; } else{ cout << (s.sz-1)*9+(s[0]-'0')-1 << endl; } return 0; }