結果

問題 No.280 歯車の問題(1)
ユーザー NTstuNTstu
提出日時 2016-06-14 18:15:10
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 599 bytes
コンパイル時間 198 ms
コンパイル使用メモリ 24,320 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 19:31:28
合計ジャッジ時間 2,535 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 0 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 0 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 0 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 0 ms
5,376 KB
testcase_13 AC 0 ms
5,376 KB
testcase_14 AC 0 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 0 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 0 ms
5,376 KB
testcase_20 AC 0 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 0 ms
5,376 KB
testcase_23 AC 0 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 0 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 0 ms
5,376 KB
testcase_29 AC 1 ms
5,376 KB
testcase_30 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:17:13: warning: ‘char* gets(char*)’ is deprecated [-Wdeprecated-declarations]
   17 |         gets(str);
      |         ~~~~^~~~~
In file included from /usr/include/stdio.h:894,
                 from main.cpp:2:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:240:1: note: declared here
  240 | gets (char *__str)
      | ^~~~
main.cpp:17:13: warning: ignoring return value of ‘char* gets(char*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   17 |         gets(str);
      |         ~~~~^~~~~
/usr/bin/ld: /tmp/cc6dvwc5.o: in function `main':
main.cpp:(.text.startup+0x30): 警告: the `gets' function is dangerous and should not be used.

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>

int main(){

	int N = 0;

	long int initgear = 0;
	long int currentgear = 0;
	long int beforegear = 0;
	long int lastgear = 0;

	char str[20];
	long int c = 0;

	gets(str);
	N = atoi(str);

	for(int i = 0; i < N; i++){

		int j = 0;

		while ((c = getchar()) != EOF){

			if(c == ' '){
				str[j] = '\0';
				break;
			}

			str[j] = c;
			j++;
		}

		currentgear = atoi(str);
		beforegear = currentgear;


		if(i == 0){
			initgear = currentgear;
		}
		if(i == N-1)
			lastgear = currentgear;

	}


	printf("%ld/%ld", lastgear, initgear);

	return 0;

}



0