結果
| 問題 | No.47 ポケットを叩くとビスケットが2倍 |
| コンテスト | |
| ユーザー |
Hissha_
|
| 提出日時 | 2018-03-29 21:42:09 |
| 言語 | C11(gcc12 gnu拡張) (gcc 12.4.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 5,000 ms |
| コード長 | 562 bytes |
| 記録 | |
| コンパイル時間 | 80 ms |
| コンパイル使用メモリ | 32,208 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2026-03-08 16:16:24 |
| 合計ジャッジ時間 | 586 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:17:29: warning: implicit declaration of function ‘pow’ [-Wimplicit-function-declaration]
17 | while(n>=(int)pow(2,i)){
| ^~~
main.c:2:1: note: include ‘<math.h>’ or provide a declaration of ‘pow’
1 | #include <stdio.h>
+++ |+#include <math.h>
2 |
main.c:17:29: warning: incompatible implicit declaration of built-in function ‘pow’ [-Wbuiltin-declaration-mismatch]
17 | while(n>=(int)pow(2,i)){
| ^~~
main.c:17:29: note: include ‘<math.h>’ or provide a declaration of ‘pow’
main.c:27:25: warning: incompatible implicit declaration of built-in function ‘pow’ [-Wbuiltin-declaration-mismatch]
27 | if(n-(int)pow(2,i-1)==0){
| ^~~
main.c:27:25: note: include ‘<math.h>’ or provide a declaration of ‘pow’
main.c:11:15: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
11 | scanf("%d",&n);
| ^~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
int main(void) {
// your code goes here
int i=0, n;
scanf("%d",&n);
// printf("%d",(int)pow(2,n));
while(n>=(int)pow(2,i)){
i++;
}
// printf("%d",n-(int)pow(2,i-1));
if(n-(int)pow(2,i-1)==0){
printf("%d",i-1);
}else{
printf("%d",i);
}
return 0;
}
Hissha_