結果
| 問題 | No.280 歯車の問題(1) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-06-14 18:15:10 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 599 bytes |
| 記録 | |
| コンパイル時間 | 301 ms |
| コンパイル使用メモリ | 39,552 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-04-25 16:55:42 |
| 合計ジャッジ時間 | 3,307 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 31 |
コンパイルメッセージ
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/ccaemY6R.o: in function `main':
main.cpp:(.text.startup+0x19): 警告: the `gets' function is dangerous and should not be used.
ソースコード
#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;
}