QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#646736#7692. Prof. Fumblemore and the Collatz Conjecturezeyu#AC ✓0ms3840kbC++232.8kb2024-10-17 05:12:082024-10-17 05:12:08

Judging History

你现在查看的是最新测评结果

  • [2024-10-17 05:12:08]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3840kb
  • [2024-10-17 05:12:08]
  • 提交

answer

#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
#define pl pair<ll, ll>
#define pi pair<int, int>
#define minpq priority_queue<ll, vector<ll>, greater<ll>>
using namespace std;

#if 1
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '['; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "]";}
void _print() {cerr << endl << flush;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define debug(x...) cerr << "*["<<__LINE__<<"]\t"<< #x << " = "; _print(x)
#endif

const ll mod = 1e9 + 7;

template<typename T> bool chkmin(T &a, T b){return (b < a) ? a = b, 1 : 0;}
template<typename T> bool chkmax(T &a, T b){return (b > a) ? a = b, 1 : 0;}
ll gcd(ll a, ll b) {if(b == 0){return a;} return gcd(b, a % b);}

ostream& operator<<(ostream& dest, __int128_t value){
    ostream::sentry s( dest );
    if (s) {
        __uint128_t tmp = value < 0 ? -value : value;
        char buffer[128];
        char* d = std::end(buffer);
        do{
            -- d;
            *d = "0123456789"[tmp % 10];
            tmp /= 10;
        } while (tmp != 0);
        if (value < 0) {
            -- d;
            *d = '-';
        }
        int len = end(buffer) - d;
        if (dest.rdbuf()->sputn(d, len) != len) {
            dest.setstate(ios_base::badbit);
        }
    }
    return dest;
}

__int128_t inf = (__int128_t)1 << 100;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s; cin >> s; int n = s.size();
	__int128_t ans = inf;
	for (int i = 0; i <= 47; i ++){
		__int128_t cur = (__int128_t)1 << i;
		bool bad = false;
		for (int j = n - 1; j >= 0; j --){
			if (s[j] == 'E') cur *= 2;
			else{
				if ((cur - 1) % 3 != 0){
					bad = true;
					break;
				} else{
					cur = (cur - 1) / 3;
					if (cur % 2 == 0){
						bad = true; break;
					}
				}
			}
			if (!(cur & (cur - 1))) bad = true;
		}
		if (! bad) ans = min(ans, cur);
	}
	if (ans == inf) cout << "INVALID";
	else cout << ans;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3816kb

input:

EEOEO

output:

12

result:

ok single line: '12'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

EEOOEO

output:

INVALID

result:

ok single line: 'INVALID'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

OEOEOEOEOEOEOEEEEEEOEEEOEEEOEEEOEOEEOEEEO

output:

383

result:

ok single line: '383'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

OEOEEEEEOEOEEEEOEEEEOEOEOEEOEEEO

output:

931

result:

ok single line: '931'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

OEEOEEOEEOEOEOEOEEEEEEOEOEEOEEOEEEEOEOEOEEOEEEO

output:

641

result:

ok single line: '641'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3560kb

input:

OEOEEOEEOEEOEEOEEEEOEEEOEOEOEEEEEO

output:

683

result:

ok single line: '683'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3840kb

input:

OEEOEEEOEOEEEEOEEEEOEOEOEEOEEEO

output:

465

result:

ok single line: '465'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

OEEOEEOEOEOEOEEEEEEOEOEEOEEOEEEEOEOEOEEOEEEO

output:

481

result:

ok single line: '481'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

OEEOEOEO

output:

201

result:

ok single line: '201'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3504kb

input:

OEEEEOEEOEOEEEOEOEEOEEEO

output:

133

result:

ok single line: '133'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

OEOEOEOEEOEEEEEEEEEEOEOEOEEOEEEO

output:

943

result:

ok single line: '943'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

OEEEOEEO

output:

301

result:

ok single line: '301'

Test #13:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

OEOEOEEEEEEOEOEEOEEOEEEEOEOEOEEOEEEO

output:

407

result:

ok single line: '407'

Test #14:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

OEOEOEOEOEOEEOEEEEOEEEOEEEOEEEOEOEEOEEEO

output:

191

result:

ok single line: '191'

Test #15:

score: 0
Accepted
time: 0ms
memory: 3652kb

input:

OEEEOEO

output:

605

result:

ok single line: '605'

Test #16:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

OEOEOEOEEOEEEEOEEEOEEEOEEEOEOEEOEEEO

output:

431

result:

ok single line: '431'

Test #17:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

OEOEEEOEEEOEOEOEEEOEEEEOEOEEEOEOEEOEEEO

output:

563

result:

ok single line: '563'

Test #18:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

OEEOEEEEEOEEOEEEO

output:

241

result:

ok single line: '241'

Test #19:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

OEEEOEEEEOEOEEEOEOEEOEEEO

output:

269

result:

ok single line: '269'

Test #20:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

EEOEOEOEEOEEEEOEOEEOEEOEEEEOEOEOEEOEEEO

output:

540

result:

ok single line: '540'

Test #21:

score: 0
Accepted
time: 0ms
memory: 3652kb

input:

OEOEOEOEOEOEEEEEEOEEEOEEEOEEEOEOEEOEEEO

output:

575

result:

ok single line: '575'

Test #22:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

EEOEEOEOEEEEEOEOEOEEEEEO

output:

868

result:

ok single line: '868'

Test #23:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

OEOEOEO

output:

26512143

result:

ok single line: '26512143'

Test #24:

score: 0
Accepted
time: 0ms
memory: 3776kb

input:

OEOEOEEO

output:

13256071

result:

ok single line: '13256071'

Test #25:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

EEO

output:

20

result:

ok single line: '20'

Test #26:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

EOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEE

output:

INVALID

result:

ok single line: 'INVALID'

Test #27:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEO

output:

43980465111040

result:

ok single line: '43980465111040'

Test #28:

score: 0
Accepted
time: 0ms
memory: 3504kb

input:

EEEEEEEEEEOEEEOEEEEOEOEEOEEEEEOEEEEEEEOEEOEEEEEEEO

output:

7321693729792

result:

ok single line: '7321693729792'

Test #29:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

EEEOEEEOEEOEEEEEOEEEEEEEOEEEEEEEEEEEEEEEEOEEEEEO

output:

1028529777000

result:

ok single line: '1028529777000'