AtCoder Beginner Contest 196 C
種別: 記事
カテゴリ: 競技プログラミング
サブカテゴリ: AtCoder > AtCoder Beginner Contest 196
タグ: #解いた問題
(工事中)
2021年3月20日にAtCoder で開催されたコンテストであるAtCoder Beginner Contest 196 のC問題に関するメモ
解き方
解答例
下は上記の方法で解いたときの提出結果である。また、その提出の際に提出したソースコードをその下に転記する。
code: C
#include <stdio.h>
#include <string.h>
int main () {
char n15 = "";
int n_len = 0;
int ans = 0;
int res = 0;
res = scanf("%s", n);
n_len = strlen(n);
if (n_len % 2 == 0) {
int i = 0;
int ans_array15 = {};
int isPlus1 = 0;
int isNotPlus1 = 0;
int ans_small = 1;
for (int i = 0; i < n_len / 2 - 1; i++) {
ans_arrayi = ni - '0';
if (i == 0) {
ans_arrayi -= 1;
}
for (int j = i + 1; j < n_len / 2; j++) {
ans_arrayi *= 10;
}
ans += ans_arrayi;
}
ans += nn_len / 2 - 1 - '0';
if (n_len / 2 - 1 < 1) {
ans -= 1;
}
for (int i = 0; i < n_len / 2; i++) {
if (isPlus1 < 1) {
if (ni > ni + n_len / 2) {
isNotPlus1 = 1;
}
}
if (isNotPlus1 < 1) {
if (ni < ni + n_len / 2) {
isPlus1 = 1;
}
}
}
if (isNotPlus1 == 0) {
ans += 1;
}
for (int i = 0; i < n_len / 2 - 1; i++) {
ans_small *= 10;
}
ans += ans_small - 1;
} else {
ans = 1;
for (int i = 0; i < n_len / 2; i++) {
ans *= 10;
}
ans -= 1;
}
printf("%d\n",ans);
return 0;
}
私の提出一覧
table: submissions_atcoder_begginer_contest_196_C
提出のURL 提出時刻 結果 備考
1回目 https://atcoder.jp/contests/abc196/submissions/21092124 2021-03-20T21:54:52+0900 AC
感想