結果

問題 No.2198 Concon Substrings (COuNt-CONstruct Version)
ユーザー boatmuscles
提出日時 2023-01-21 23:28:27
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 1,207 bytes
コンパイル時間 580 ms
コンパイル使用メモリ 55,928 KB
最終ジャッジ日時 2025-02-10 06:18:48
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 104
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:13:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |     scanf("%lld", &N);
      |     ~~~~~^~~~~~~~~~~~

ソースコード

diff #
プレゼンテーションモードにする

#include<cstdio>
#include<string>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define rep2(i, a, b) for (int i = (int)a; i < (int)(b); ++i)
#define rrep2(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); --i)
int main(){
ll N;
scanf("%lld", &N);
if(N < 10){
printf("co");
rep(_,N) printf("n");
return 0;
}
int cubic = 0, ng = 10001;
while(ng - cubic > 1){
int mid = (ng + cubic) / 2;
if(((ll)mid * mid + 1) * mid <= N) cubic = mid;
else ng = mid;
}
N -= ((ll)cubic*cubic + 1)*cubic;
int quotient_square = N/((ll)cubic*cubic);
N %= (ll)cubic*cubic;
int quotient_one = N/cubic;
int remainder = N%cubic;
string answer = "co";
answer.resize(cubic*3 + quotient_square + quotient_one + remainder + 1);
auto it = answer.begin() + 2;
rep(_,remainder) *it++ = 'n';
rep(_,quotient_one) *it++ = 'o';
rep(_,cubic-1) *it++ = 'c';
rep(_,cubic + quotient_square) *it++ = 'o';
rep(_,cubic) *it++ = 'n';
printf("%s\n", answer.c_str());
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0