제출 #22850

#제출 시각아이디문제언어결과실행 시간메모리
22850이대회 트래쉬 대회에야옹 (#40)Fully Generate (KRIII5_FG)C++98
0 / 7
500 ms41756 KiB
#include <iostream>
#include <cstdio>
#include <map>

using namespace std;

map<long long, long long> mp;

int main()
{
    long long n;
    long long sum = 0;
    scanf("%lld", &n);

    if (n == 1)
    {
        cout << 1;
        return 0;
    }

    mp[1] = 1;
    sum += mp[1];

    long long i,j;
    long long mul =1;
    for (i = 2; i <= n; i++)
    {
        mp[i] = 1 + mp[i - mp[mp[i - 1]]];
        sum += mp[i];
        if(sum > n)
        {
          sum -= mp[i];
          while(1)
          {
            if(sum == n)
             break;
            mul = (mul*i)%1000000007;
            sum++;
          }
        }
        else
        {
          for(j=0; j<mp[i]; j++)
          {
            mul = (mul*i)%1000000007;
          }
        }
    }

    cout << mul << endl;
    return 0;
}

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

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