結果

問題 No.2868 Another String of yuusaan
ユーザー 沙耶花沙耶花
提出日時 2024-08-30 22:30:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,001 bytes
コンパイル時間 4,256 ms
コンパイル使用メモリ 263,248 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-08-30 22:30:23
合計ジャッジ時間 5,205 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 WA -
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 WA -
testcase_10 AC 2 ms
6,940 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
6,944 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000001
string s = "yuusaan";
long long sz[100],cnt[100];
void solve(long long n,long long K){
	if(n==0){
		cout<<"y"<<endl;
		exit(0);
	}
	if(K==0){
		cout<<s[n]<<endl;
		exit(0);
	}
	n--;
	if(K>=100){
		solve(n,100);
	}
	else{
		for(int j=1;j<s.size();j++){
			if(s[j]=='a'||s[j]=='u'){
				long long t = sz[K];
				if(n-t >= 0){
					n -= t;
				}
				else{
					solve(n,K-1);
				}
			}
			else{
				if(n==0){
					cout<<s[j]<<endl;
					exit(0);
				}
				else n--;
			}
		}
	}
}
int main(){
	long long N,K;
	cin>>N>>K;
	sz[1] = 7;
	cnt[1] = 4;
	for(int i=2;i<100;i++){
		sz[i] = sz[i-1] + cnt[i-1] * 6;
		cnt[i] = cnt[i-1] * 4;
		sz[i] = min(sz[i], (long long)Inf64);
		cnt[i] = min(cnt[i],(long long) Inf64);
	}
	K--;
	N--;
	solve(K,N);
    return 0;
}
0