結果

問題 No.1458 Segment Function
ユーザー 👑 NachiaNachia
提出日時 2021-03-31 22:17:14
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 667 bytes
コンパイル時間 2,265 ms
コンパイル使用メモリ 194,408 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 17:39:04
合計ジャッジ時間 3,394 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 6 ms
5,376 KB
testcase_09 AC 6 ms
5,376 KB
testcase_10 AC 6 ms
5,376 KB
testcase_11 AC 6 ms
5,376 KB
testcase_12 AC 6 ms
5,376 KB
testcase_13 AC 6 ms
5,376 KB
testcase_14 AC 6 ms
5,376 KB
testcase_15 AC 6 ms
5,376 KB
testcase_16 AC 6 ms
5,376 KB
testcase_17 AC 6 ms
5,376 KB
testcase_18 AC 10 ms
5,376 KB
testcase_19 AC 10 ms
5,376 KB
testcase_20 AC 10 ms
5,376 KB
testcase_21 AC 10 ms
5,376 KB
testcase_22 AC 10 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 6 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 10 ms
5,376 KB
testcase_27 AC 10 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 6 ms
5,376 KB
testcase_30 AC 6 ms
5,376 KB
testcase_31 AC 6 ms
5,376 KB
testcase_32 AC 7 ms
5,376 KB
testcase_33 AC 6 ms
5,376 KB
testcase_34 AC 6 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0