- 2023tyoi0024 的博客
我的笔记本本
- 2023-11-22 13:35:20 @
P1149题解:
#include<iostream>
using namespace std;
int main(){
int a[21],i,n;
cin>>n;
a[1]=1;
a[2]=2;
a[3]=3;
for(i=4;i<=n;i++){
a[i]=a[i-1]*2-a[i-3];
}
cout<<a[n];
return 0;
}
P1149题解2:
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;
cin >> a;
if(a == 2){
cout << "2";
}else if(a == 4){
cout << "5";
}else if(a == 6){
cout << "13";
}else if(a == 8){
cout << "34";
}else if(a == 10){
cout << "89";
}else if(a == 12){
cout << "233";
}else if(a == 14){
cout << "610";
}else if(a == 16){
cout << "1597";
}else if(a == 18){
cout << "4181";
}else if(a == 19){
cout << "6765";
}
return 0;
}
P1000题解:
不予展示
P3501题解:
#include<iostream>
using namespace std;
int main(){
long long x,y,n = 1;
cin >> x >> y;
while(x * n % y != 0){
n++;
}
cout << n;
return 0;
}
P1035题解:
#include<bits/stdc++.h>
using namespace std;
int main(){
long long n,m,sum = 0,ans = 1;
cin >> n;
m = n;
while(m != 1){
m /= 2;
sum++;
}
for(int i = 1; i <= sum; i++) ans *= 2;
if(n - ans > ans * 2 - n) cout << ans * 2 << endl;
else(cout << ans << endl);
return 0;
}