結果

問題 No.1458 Segment Function
ユーザー auauaauaua
提出日時 2021-04-01 18:42:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 2,416 bytes
コンパイル時間 1,759 ms
コンパイル使用メモリ 167,824 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 17:42:20
合計ジャッジ時間 3,604 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 9 ms
5,376 KB
testcase_09 AC 8 ms
5,376 KB
testcase_10 AC 8 ms
5,376 KB
testcase_11 AC 9 ms
5,376 KB
testcase_12 AC 8 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 13 ms
5,376 KB
testcase_19 AC 12 ms
5,376 KB
testcase_20 AC 12 ms
5,376 KB
testcase_21 AC 13 ms
5,376 KB
testcase_22 AC 13 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 7 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 9 ms
5,376 KB
testcase_33 AC 9 ms
5,376 KB
testcase_34 AC 8 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
#define double long double
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
//typedef long double ld;
typedef complex<double> Complex;
const ll INF=1e9+7;
const ll MOD=998244353;
const ll inf=INF*INF;
const ll mod=MOD;
const ll MAX=2000010;

string f(string t){
    ll k=0;
    ll i=0;
    if(t[0]=='-'){
        k++;
        i++;
    }
    while(i<t.size()){
        if(t[i]=='0')k+=6;
        if(t[i]=='1')k+=2;
        if(t[i]=='2')k+=5;
        if(t[i]=='3')k+=5;
        if(t[i]=='4')k+=4;
        if(t[i]=='5')k+=5;
        if(t[i]=='6')k+=6;
        if(t[i]=='7')k+=4;
        if(t[i]=='8')k+=7;
        if(t[i]=='9')k+=6;
        i++;
    }
    string res="";
    while(k){
        res+=(char)('0'+k%10);
        k/=10;
    }
    reverse(all(res));
    return res;
}

signed main(){
    string p;cin>>p;
    string n;cin>>n;
    if(n.size()==1&&n[0]-'0'<=4){
        string nxt=p;
        rep(j,n[0]-'0'){
            nxt=f(nxt);
        }
        cout<<nxt<<endl;
    }else{
        string nxt=p;

        rep(j,4){
            nxt=f(nxt);
        }

        if(n.size()==1){
            ll m=n[0]-'0';
            m-=4;
            if(m==0){
                cout<<nxt[0]<<endl;
            }else if(m==1){
                if(nxt[0]=='0'||nxt[0]=='6'||nxt[0]=='9')cout<<6<<endl;
                if(nxt[0]=='2'||nxt[0]=='3'||nxt[0]=='5')cout<<5<<endl;
                if(nxt[0]=='4'||nxt[0]=='7')cout<<4<<endl;
                if(nxt[0]=='1')cout<<2<<endl;
                if(nxt[0]=='8')cout<<7<<endl;
            }else{
                if(nxt[0]=='0'||nxt[0]=='6'||nxt[0]=='9')cout<<6<<endl;
                if(nxt[0]=='1'||nxt[0]=='2'||nxt[0]=='3'||nxt[0]=='5')cout<<5<<endl;
                if(nxt[0]=='4'||nxt[0]=='7'||nxt[0]=='8')cout<<4<<endl;
            }
        }else{
            if(nxt[0]=='0'||nxt[0]=='6'||nxt[0]=='9')cout<<6<<endl;
            if(nxt[0]=='1'||nxt[0]=='2'||nxt[0]=='3'||nxt[0]=='5')cout<<5<<endl;
            if(nxt[0]=='4'||nxt[0]=='7'||nxt[0]=='8')cout<<4<<endl;
        }
    }
}
0