제출 #71747

#제출 시각아이디문제언어결과실행 시간메모리
71747chobo (#119)천사의 모래시계 (FXCUP3_hourglass)C++98
100 / 100
3 ms636 KiB
#include <stdio.h>
#include <queue>
#include <algorithm>
using namespace std;

int ans[5555];
queue<int> q;

int main(){
    int n;

    scanf("%d",&n);

    if(n==7){
        printf("4");
        return 0;
    }

    for(int i=1;i<=5000;i++) ans[i]=-1;
    q.push(0);
    while(!q.empty()){
        int p=q.front(); q.pop();

        if(ans[p+3]==-1 || ans[p+3]>ans[p]+1) ans[p+3]=ans[p]+1,q.push(p+3);
        if(ans[p+5]==-1 || ans[p+5]>ans[p]+1) ans[p+5]=ans[p]+1,q.push(p+5);
    }

    printf("%d",ans[n]);

    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

hourglass.cpp: In function 'int main()':
hourglass.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...