結果

問題 No.280 歯車の問題(1)
コンテスト
ユーザー NTstu
提出日時 2016-06-14 18:15:10
言語 C++11
(gcc 15.3.0 + boost 1.92.0)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 599 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 145 ms
コンパイル使用メモリ 43,788 KB
実行使用メモリ 9,916 KB
最終ジャッジ日時 2026-10-31 09:13:35
合計ジャッジ時間 3,423 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge7_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 32 WA * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 main.cpp:2:
/usr/include/stdio.h:667:14: note: declared here
  667 | extern char *gets (char *__s) __wur __attribute_deprecated__;
      |              ^~~~
/usr/bin/ld: /tmp/cci4adST.o: in function `main':
main.cpp:(.text.startup+0x19): 警告: the `gets' function is dangerous and should not be used.

ソースコード

diff #
raw source code

#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