Submission #582569

# Submission time Handle Problem Language Result Execution time Memory
582569 2022-06-24T06:06:10 Z 박상훈(#8369) Fibonacci representations (CEOI18_fib) C++17
0 / 100
0 ms 212 KB
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
const int MOD = 1e9+7;
multiset<int> st;

ll pw(ll a, ll e){
    if (!e) return 1;
    ll ret = pw(a, e/2);
    if (e&1) return ret*ret%MOD*a%MOD;
    return ret*ret%MOD;
}

ll INV(ll x){
    return pw(x, MOD - 2);
}

int main(){
    int n;
    scanf("%d", &n);

    ll ans = 1;
    st.insert(0);
    for (int i=1;i<=n;i++){
        int x;
        scanf("%d", &x);
        auto iter = st.insert(x);
        ans = (ans * (x-*prev(iter))/2 ) % MOD;
        if (next(iter)!=st.end()){
            //printf(" %d %d %d\n", *prev(iter), x, *next(iter));
            ans = (ans * INV( (*next(iter)-*prev(iter)) /2 ) ) % MOD;
            ans = (ans * (*next(iter)-x)/2) % MOD;
        }
        printf("%lld\n", ans);
    }
    return 0;
}

Compilation message

fib.cpp: In function 'int main()':
fib.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
fib.cpp:27:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |         scanf("%d", &x);
      |         ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -