結果
| 問題 |
No.2198 Concon Substrings (COuNt-CONstruct Version)
|
| コンテスト | |
| ユーザー |
chro_96
|
| 提出日時 | 2023-01-20 23:08:31 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,918 bytes |
| コンパイル時間 | 255 ms |
| コンパイル使用メモリ | 31,452 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-23 11:07:26 |
| 合計ジャッジ時間 | 4,151 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 103 WA * 1 |
ソースコード
#include <stdio.h>
long long gcd (long long a, long long b, long long *x, long long *y) {
long long ans = 0LL;
if (b <= 0LL) {
*x = 1LL;
*y = 0LL;
return a;
}
ans = gcd(b, a%b, y, x);
*y -= (a/b)*(*x);
return ans;
}
int main () {
long long m = 0LL;
int res = 0;
long long c = 0LL;
long long o = 0LL;
long long n = 0LL;
long long diff = 0LL;
long long d = 0LL;
long long x = 0LL;
long long y = 0LL;
char ans[60001] = "";
int idx = 0;
long long tmp_c = 0LL;
long long tmp_o = 0LL;
long long tmp_n = 0LL;
res = scanf("%lld", &m);
if (m == 0LL) {
printf("a\n");
return 0;
}
while (c*c*c < m) {
c += 1LL;
}
o = c;
n = c+1LL;
while (c*o*n-m < c*n-c-n) {
o += 1LL;
}
diff = c*o*n-m;
d = gcd(c, n, &x, &y);
x *= diff/d;
y *= diff/d;
if (x < 0LL) {
long long mul = 1LL+(-x-1LL)/n;
x += mul*n;
y -= mul*c;
}
if (y < 0LL) {
long long mul = 1LL+(-y-1LL)/c;
x -= mul*n;
y += mul*c;
}
tmp_c = c;
tmp_o = o;
tmp_n = n;
//printf("%lld %lld %lld %lld %lld\n", c, o, n, x, y);
for (int i = 0; i < (int)(y/c); i++) {
ans[idx] = 'o';
idx++;
tmp_o -= 1LL;
}
while (tmp_c > y%c) {
ans[idx] = 'c';
idx++;
tmp_c -= 1LL;
}
if (tmp_c > 0LL) {
ans[idx] = 'o';
idx++;
tmp_o--;
}
while (tmp_c > 0LL) {
ans[idx] = 'c';
idx++;
tmp_c -= 1LL;
}
while (tmp_o > 1LL+x/n) {
ans[idx] = 'o';
idx++;
tmp_o -= 1LL;
}
for (int i = 0; i < (int)(x%n); i++) {
ans[idx] = 'n';
idx++;
tmp_n -= 1LL;
}
ans[idx] = 'o';
idx++;
tmp_o--;
while (tmp_n > 0LL) {
ans[idx] = 'n';
idx++;
tmp_n -= 1LL;
}
for (int i = 0; i < (int)(x/n); i++) {
ans[idx] = 'o';
idx++;
tmp_o -= 1LL;
}
ans[idx] = '\0';
printf("%s\n", ans);
return 0;
}
chro_96