結果
| 問題 |
No.1458 Segment Function
|
| コンテスト | |
| ユーザー |
Nachia
|
| 提出日時 | 2021-03-31 22:17:14 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 11 ms / 2,000 ms |
| コード長 | 667 bytes |
| コンパイル時間 | 2,181 ms |
| コンパイル使用メモリ | 192,648 KB |
| 最終ジャッジ日時 | 2025-01-20 03:47:07 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 32 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)
int fD[10] = {6,2,5,5,4,5,6,4,7,6};
int f(const string& S){
int res=0;
for(char c:S){
if(c=='-') res+=1;
if('0'<=c && c<='9') res+=fD[c-'0'];
}
return res;
}
int f(int S){
int res=0;
if(S==0) return 6;
if(S<0){ res+=2; S*=-1; }
while(S!=0){ res+=fD[S%10]; S/=10; }
return res;
}
int main(){
string P,N; cin>>P>>N;
int Nd=0;
if(N.size()>=3) Nd=1000;
else Nd=stod(N);
int A=0;
if(Nd==0) cout<<P<<"\n";
else{
A=f(P); Nd--;
rep(i,Nd) A=f(A);
cout<<A<<"\n";
}
return 0;
}
Nachia