답안 #258060

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
258060 2020-08-05T09:37:02 Z tqbfjotld Lucky Numbers (RMI19_lucky) C++14
28 / 100
92 ms 1528 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define MOD 1000000007LL

int n,q;
int arr[100005];
int memo[100005];

int func(int a){
    if (memo[a]!=-1) return memo[a];
    if (a==0) return memo[0] = 0;
    if (a==1) return memo[1] = 1;
    return memo[a] = (10*func(a-1)-func(a-2))%MOD;
}

 main(){
    scanf("%lld%lld",&n,&q);
    for (int x = 0; x<n; x++){
        char c;
        scanf(" %c",&c);
        arr[x] = c-'0';
    }
    memset(memo,-1,sizeof(memo));
    func(n+1);
    int ans = 1;
    for (int x = n-1;x>=0; x--){
        if (arr[x]==0){
            continue;
        }
        //printf("ans += %lld * %lld - %lld\n",arr[x],memo[n-x],memo[n-1-x]);
        ans += arr[x]*memo[n-x]-memo[n-1-x];
        ans %= MOD;
    }
    printf("%lld\n",(ans+MOD)%MOD);
    while (q--){
        int a,b,c;
        scanf("%lld%lld%lld",&a,&b,&c);
        if (a==2){
            arr[b-1] = c;
        }
        else{
            int ans = 1;
            for (int x = c-1; x>=b-1; x--){
                if (arr[x] == 0) continue;
                ans += arr[x]*memo[c-x]-memo[c-1-x];
                ans %=MOD;
            }
            printf("%lld\n",(ans+MOD)%MOD);
        }
    }
}

Compilation message

lucky.cpp:18:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
  main(){
       ^
lucky.cpp: In function 'int main()':
lucky.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld%lld",&n,&q);
     ~~~~~^~~~~~~~~~~~~~~~~~
lucky.cpp:22:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf(" %c",&c);
         ~~~~~^~~~~~~~~~
lucky.cpp:39:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld%lld%lld",&a,&b,&c);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1152 KB Output is correct
2 Correct 1 ms 1152 KB Output is correct
3 Correct 1 ms 1152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1152 KB Output is correct
2 Correct 1 ms 1152 KB Output is correct
3 Correct 1 ms 1152 KB Output is correct
4 Correct 1 ms 1152 KB Output is correct
5 Correct 1 ms 1152 KB Output is correct
6 Correct 1 ms 1152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 92 ms 1528 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 92 ms 1528 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1152 KB Output is correct
2 Correct 1 ms 1152 KB Output is correct
3 Correct 1 ms 1152 KB Output is correct
4 Correct 1 ms 1152 KB Output is correct
5 Correct 1 ms 1152 KB Output is correct
6 Correct 1 ms 1152 KB Output is correct
7 Incorrect 92 ms 1528 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1152 KB Output is correct
2 Correct 1 ms 1152 KB Output is correct
3 Correct 1 ms 1152 KB Output is correct
4 Correct 1 ms 1152 KB Output is correct
5 Correct 1 ms 1152 KB Output is correct
6 Correct 1 ms 1152 KB Output is correct
7 Incorrect 92 ms 1528 KB Output isn't correct
8 Halted 0 ms 0 KB -