답안 #1068780

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1068780 2024-08-21T12:05:11 Z cpdreamer Fibonacci representations (CEOI18_fib) C++17
5 / 100
120 ms 262144 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <utility>
#define V vector
#define F first
#define S second
#define P pair
#define pb push_back
#define all(v) v.begin(),v.end()
typedef long long ll;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,
        tree_order_statistics_node_update> indexed_set;
static int called = 0;const long long MOD = 1e9+7; // 1e9 + 7

void file(){
    freopen("input.txt.txt","r",stdin);
    freopen("output.txt.txt","w",stdout);
}
ll binary_expo(ll a,ll b,ll m){
    ll res=1;
    while(b){
        if(b%2==1){res=(res*a)%m;b--;}
        b/=2;
        a=(a*a)%m;
    }
    return res%m;
}
set<map<int,int>>st1;
set<map<int,int>>st;
bool prime(ll p){
    for(int i=0;i<500;i++) {
        ll b = rand()%p;
        if(b!=0) {
            ll res = binary_expo(b, p, p);
            if (res != b % p)
                return false;
        }
    }
    return true;
}
void  solve() {
    int fib[31];
    fib[1]=1;
    fib[2]=2;
    for(int i=3;i<=30;i++){
        fib[i]=fib[i-1]+fib[i-2];
    }
    int n;
    cin>>n;
    int A[n];
    for(int i=0;i<n;i++)
        cin>>A[i];
    for(int i=0;i<n;i++){
        if(i==0)
            A[i]=fib[A[i]];
        else
            A[i]=fib[A[i]]+A[i-1];
    }
    int max_v=A[n-1];
    int dp[max_v+1];
    memset(dp,0,sizeof(dp));
    dp[0]=1;
    for(int i=1;i<=30;i++){
        for(int j=max_v;j-fib[i]>=0;j--){
            dp[j]+=dp[j-fib[i]];
        }
        int k;
        k++;
    }
    for(int i=0;i<n;i++)
        cout<<dp[A[i]]<<endl;
}
int main(){
    //file();
    solve();
}

Compilation message

fib.cpp: In function 'void file()':
fib.cpp:18:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     freopen("input.txt.txt","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
fib.cpp:19:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |     freopen("output.txt.txt","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fib.cpp: At global scope:
fib.cpp:15:12: warning: 'called' defined but not used [-Wunused-variable]
   15 | static int called = 0;const long long MOD = 1e9+7; // 1e9 + 7
      |            ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 440 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 440 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Runtime error 120 ms 262144 KB Execution killed with signal 9
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 440 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Runtime error 120 ms 262144 KB Execution killed with signal 9
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 7
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 440 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Runtime error 120 ms 262144 KB Execution killed with signal 9
9 Halted 0 ms 0 KB -