Submission #4565168


Source Code Expand

Copy
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

const ll mod = 1e9 + 7;
const ll inf = 1e18;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    // input
    ll P;
    cin >> P;

    ll ans[1001];
    ans[1000] = 1789997546303;

    for(int i=999; i>=0; i--){
        ll X = ans[i+1];
        if(X%2==0){
            ans[i] = X/2;
        }else{
            ans[i] = 3*X+1;
        }
    }
    p(ans[P]);
    
    return 0;
}

Submission Info

Submission Time
Task F - コラッツ問題
User peroon
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1077 Byte
Status AC
Exec Time 2 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 17
Set Name Test Cases
Sample example01.txt, example02.txt
All example01.txt, example02.txt, subtask_01_01.txt, subtask_01_02.txt, subtask_01_03.txt, subtask_01_04.txt, subtask_01_05.txt, subtask_01_06.txt, subtask_01_07.txt, subtask_01_08.txt, subtask_01_09.txt, subtask_01_10.txt, subtask_01_11.txt, subtask_01_12.txt, subtask_01_13.txt, subtask_01_14.txt, subtask_01_15.txt
Case Name Status Exec Time Memory
example01.txt AC 2 ms 256 KB
example02.txt AC 2 ms 256 KB
subtask_01_01.txt AC 2 ms 256 KB
subtask_01_02.txt AC 2 ms 256 KB
subtask_01_03.txt AC 2 ms 256 KB
subtask_01_04.txt AC 2 ms 256 KB
subtask_01_05.txt AC 2 ms 256 KB
subtask_01_06.txt AC 2 ms 256 KB
subtask_01_07.txt AC 1 ms 256 KB
subtask_01_08.txt AC 1 ms 256 KB
subtask_01_09.txt AC 1 ms 256 KB
subtask_01_10.txt AC 1 ms 256 KB
subtask_01_11.txt AC 1 ms 256 KB
subtask_01_12.txt AC 2 ms 256 KB
subtask_01_13.txt AC 1 ms 256 KB
subtask_01_14.txt AC 1 ms 256 KB
subtask_01_15.txt AC 1 ms 256 KB