Submission #3624551
Source Code Expand
#include <limits.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> // 内部定数 #define D_STR_MAX 100000 // 最大文字列数 // 内部変数 static FILE *szpFpI; // 入力 static char sc1Str[D_STR_MAX + 5]; // 文字列 static int siSLen; // 文字列長 static int siCCnt; // 変換回数 // 改行カット // 戻り値:文字数 int fCutCrLf( char *pcpStr // <I> 文字列 ) { int i; for (i = 0; pcpStr[i] != '\0'; i++) { if (pcpStr[i] == '\n') { pcpStr[i] = '\0'; break; } } return i; } // 実行メイン int fMain( int piTNo // <I> テスト番号 1~ ) { char lc1Buf[1024]; // 入力 - セット #ifdef D_TEST sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo); szpFpI = fopen(lc1Buf, "r"); #else szpFpI = stdin; #endif // 文字列 - 取得 fgets(sc1Str, sizeof(sc1Str), szpFpI); // 文字列長 - 取得 siSLen = fCutCrLf(sc1Str); // 変換回数 - 取得 fgets(lc1Buf, sizeof(lc1Buf), szpFpI); sscanf(lc1Buf, "%d", &siCCnt); // 変換 int liNo = 0; while (siCCnt > 0) { if (liNo < siSLen - 1) { // 最終文字の前 if (sc1Str[liNo] != 'a') { // 'a'以外 int liCCnt = 'z' - sc1Str[liNo] + 1; // 'a'への変換回数 if (siCCnt >= liCCnt) { // 'a'への変換可能 siCCnt -= liCCnt; // 'a'への変換 sc1Str[liNo] = 'a'; // 'a'への変換 } } liNo++; // 次の文字へ } else { // 最終文字 sc1Str[liNo] += siCCnt % 26; // 変換 siCCnt = 0; if (sc1Str[liNo] > 'z') { sc1Str[liNo] -= 26; } } } // 結果 - 表示 printf("%s\n", sc1Str); // テストファイルクローズ #ifdef D_TEST fclose(szpFpI); #endif return 0; } int main() { #ifdef D_TEST int i; for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) { fMain(i); } #else fMain(0); #endif return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Next Letter |
User | asugen0402 |
Language | C (GCC 5.4.1) |
Score | 0 |
Code Size | 2054 Byte |
Status | WA |
Exec Time | 1 ms |
Memory | 384 KB |
Compile Error
./Main.c: In function ‘fMain’: ./Main.c:53:2: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result] fgets(sc1Str, sizeof(sc1Str), szpFpI); ^ ./Main.c:59:2: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result] fgets(lc1Buf, sizeof(lc1Buf), szpFpI); ^
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 400 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 1 ms | 128 KB |
0_01.txt | AC | 1 ms | 128 KB |
0_02.txt | AC | 1 ms | 128 KB |
1_00.txt | AC | 1 ms | 128 KB |
1_01.txt | AC | 1 ms | 128 KB |
1_02.txt | AC | 1 ms | 128 KB |
1_03.txt | AC | 1 ms | 128 KB |
1_04.txt | AC | 1 ms | 128 KB |
1_05.txt | WA | 1 ms | 128 KB |
1_06.txt | AC | 1 ms | 384 KB |
1_07.txt | WA | 1 ms | 384 KB |
1_08.txt | AC | 1 ms | 384 KB |
1_09.txt | AC | 1 ms | 384 KB |
1_10.txt | AC | 1 ms | 384 KB |
1_11.txt | AC | 1 ms | 384 KB |
1_12.txt | AC | 1 ms | 384 KB |
1_13.txt | AC | 1 ms | 384 KB |
1_14.txt | AC | 1 ms | 384 KB |
1_15.txt | AC | 1 ms | 384 KB |
1_16.txt | AC | 1 ms | 384 KB |
1_17.txt | AC | 1 ms | 384 KB |
1_18.txt | AC | 1 ms | 384 KB |
1_19.txt | AC | 1 ms | 384 KB |
1_20.txt | AC | 1 ms | 384 KB |
1_21.txt | AC | 1 ms | 384 KB |
1_22.txt | WA | 1 ms | 384 KB |
1_23.txt | AC | 1 ms | 384 KB |