4 条题解
-
0郑文翔 (13560001184) LV 8 @ 2024-5-25 22:07:16
最简代码
#include<bits/stdc++.h> using namespace std; long long n,cnt,num=10,x=9,a[10010]; int main(){ cin>>n; if(n==1)cout<<9<<endl; a[1]=9; for(int i=2;i<=n;i++){a[i]=(7*x+num)%12345;x+=a[i];num=num*10%12345;} cout<<a[n]; return 0; }
-
02024-5-19 20:18:42@
#include<iostream> #include<iomanip> #include<set> #include<string> #include<cstring> #include<algorithm> using namespace std; const int N = 1e3 + 10; int a[N] , b[N] , c = 9; int main(){ int n; cin >> n; a[1] = 8,b[1] = 1; for(int i = 2;i <= n;i++) { if(i == n) c = 8; a[i] = (a[i - 1] * 9 + b[i - 1] * 1) % 12345; b[i] = (a[i - 1] * 1 + b[i - 1] * 9) % 12345; } cout << a[n] << endl; return 0; }
-
02024-5-19 20:15:30@
#include<bits/stdc++.h> using namespace std; const int N = 1e3 + 10; int a[N] , b[N] , c = 9; int main(){ int n; cin >> n; a[1] = 8,b[1] = 1; for(int i = 2;i <= n;i++) { if(i == n) c = 8; a[i] = (a[i - 1] * 9 + b[i - 1] * 1) % 12345; b[i] = (a[i - 1] * 1 + b[i - 1] * 9) % 12345; } cout << a[n] << endl; return 0; }
-
02023-8-21 12:06:26@
#include <iostream> #define int long long using namespace std; const int N=1e3+10; const int mod=12345; int odd[N],even[N]; signed main(){ int n; cin>>n; even[1]=9;odd[1]=1; int t=9; for(int i=2;i<=n;i++){ if(i==n)t=8; odd[i]=(t*odd[i-1]+even[i-1])%mod; even[i]=(1*odd[i-1]+t*even[i-1])%mod; } cout<<even[n]<<endl; return 0; }
- 1
信息
- ID
- 1265
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 5
- 标签
- 递交数
- 114
- 已通过
- 43
- 上传者