提出 #72177342


ソースコード 拡げる

//Code by: hwng_8tk1
#include <bits/stdc++.h>
using namespace std;

// #pragma GCC optimize("O3", "unroll-loops")
// #pragma GCC target("avx2")
#define fast                        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll                          long long
#define ull                         unsigned long long
#define pii                         pair<int, int>
#define pll                         pair<ll, ll>
#define vi                          vector<int>
#define vll                         vector<ll>
#define vii                         vector<pii>
#define fi                          first
#define se                          second
#define pb                          push_back
#define all(x)                      (x).begin(), (x).end()
#define FOR(i,a,b)                  for (int i = (a); i <= (b); i++)
#define FOD(i,a,b)                  for (int i = (a); i >= (b); i--)
#define arr(a,n)                    for (int i = 0; i < n; i++) cin >> a[i];
#define __hwng_8tk1__               int main()
#define time                        (double)clock() / CLOCKS_PER_SEC
#define el                          "\n"
#define endl                        el
#define yes                         cout << "Yes\n"
#define no                          cout << "No\n"
#define task                        "hwng_8tk1"

const int mod = 998244353;
const int mod1 = 1e9 + 7;
const int inf = 1e9;
const ll inf1 = 1e18;
const int N = 1e6 + 5;
const int maxn = 1e6 + 5;

#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x << " = " << x << el;
#else
#define debug(x)
#endif
ll calc(int n){
    int res=0;
    while(n>0){
        int d=n%10;
        res+=d*d;
        n/=10;
    }
    return res;
}
__hwng_8tk1__ {
    fast;
    if(fopen(task".inp","r")) {
        freopen(task".inp","r",stdin);
        freopen(task".out","w",stdout);
    }
    int n;cin>>n;
    set<int>s;
    while(n!=1 and s.find(n)==s.end()){
        s.insert(n);
        n=calc(n);
    }
    if(n==1)yes;
    else no;
    return 0;
}

/*
>>========================================================================<<
||                                                                        ||
||  ,--.                                      ,---.   ,--.  ,--.    ,--.  ||
||  |  ,---. ,--.   ,--.,--,--,  ,---.       |  o  |,-'  '-.|  |,-./   |  ||
||  |  .-.  ||  |.'.|  ||      \| .-. |      .'   '.'-.  .-'|     /`|  |  ||
||  |  | |  ||   .'.   ||  ||  |' '-' ',----.|  o  |  |  |  |  \  \ |  |  ||
||  `--' `--''--'   '--'`--''--'.`-  / '----' `---'   `--'  `--'`--'`--'  ||
||                              `---'                                     ||
||                                                                        ||
>>========================================================================<<
*/

提出情報

提出日時
問題 B - Happy Number
ユーザ hwng_8tk1
言語 C++23 (GCC 15.2.0)
得点 200
コード長 2864 Byte
結果 AC
実行時間 1 ms
メモリ 3636 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 200 / 200
結果
AC × 3
AC × 23
セット名 テストケース
Sample sample_01.txt, sample_02.txt, sample_03.txt
All sample_01.txt, sample_02.txt, sample_03.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt
ケース名 結果 実行時間 メモリ
sample_01.txt AC 1 ms 3420 KiB
sample_02.txt AC 1 ms 3512 KiB
sample_03.txt AC 1 ms 3428 KiB
test_01.txt AC 1 ms 3552 KiB
test_02.txt AC 1 ms 3464 KiB
test_03.txt AC 1 ms 3472 KiB
test_04.txt AC 1 ms 3552 KiB
test_05.txt AC 1 ms 3472 KiB
test_06.txt AC 1 ms 3616 KiB
test_07.txt AC 1 ms 3472 KiB
test_08.txt AC 1 ms 3500 KiB
test_09.txt AC 1 ms 3428 KiB
test_10.txt AC 1 ms 3636 KiB
test_11.txt AC 1 ms 3512 KiB
test_12.txt AC 1 ms 3484 KiB
test_13.txt AC 1 ms 3500 KiB
test_14.txt AC 1 ms 3512 KiB
test_15.txt AC 1 ms 3552 KiB
test_16.txt AC 1 ms 3428 KiB
test_17.txt AC 1 ms 3636 KiB
test_18.txt AC 1 ms 3508 KiB
test_19.txt AC 1 ms 3476 KiB
test_20.txt AC 1 ms 3512 KiB