- C20250121's blog
...
- 2022-10-17 9:53:08 @
A1071
#include<bits/stdc++.h>
using namespace std;
int main(){
int i=1;
int fi=1;
int fnext=1;
int k;
cin>>k;
while (i<k){
//fi,fnext --------> fnext,fi+fnext
int fnextnext = fi + fnext;
fi =fnext ;
fnext=fnextnext;
i++;
}
cout<<fi;
return 0;
}
A1077
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int i=0;
int answer=0;
while (i<n){
//i从0~~~n-1 重复执行n次
int x;
cin>>x; //读入四位数x
int ge =x/1 %10;
int shi=x/10 %10;
int bai=x/100 %10;
int qian=x/1000%10;
if (ge>shi+bai+qian)
answer = answer + 1;
i++;
//最后一次执行之后 i变成n
}
cout<<answer;
return 0;
}
A1078
#include<bits/stdc++.h>
using namespace std;
int main() {
int n;
cin>>n;
int i=1;
int fi0=1, fi1=1, fi2=2;
double ans = 0;
while (i<=n) {
ans = ans +1.0*fi2/fi1;
fi0 = fi1;
fi1 = fi2;
fi2 = fi1+fi0;
i = i + 1;
}
cout<<fixed<<setprecision(4)<<ans<<endl;
return 0;
}
A1079
#include<stdio.h>
int main(){
int n; double ans = 0.0;
scanf ("%d", &n);
for (int i = 1;i <= n;++i)
if (i % 2 == 0) ans -= 1.0/i;
else ans += 1.0/i;
printf ("%.4lf", ans);
}
A1080
#include<iostream>
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
for(int x=2;x<=a;x++)
if(a%x==b%x && a%x==c%x)
{
cout<<x<<endl;
return 0;
}
A1083
#include<iostream>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
int s=1;
for(int i=1;i<=b;i++){
s=s*a%7;
}
if(s==0) cout<<"Sunday";
if(s==1) cout<<"Monday";
if(s==2) cout<<"Tuesday";
if(s==3) cout<<"Wednesday";
if(s==4) cout<<"Thursday";
if(s==5) cout<<"Friday";
if(s==6) cout<<"Saturday";
return 0;
}
A1084
#include<iostream>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
int s=1;
for(int i=1;i<=b;i++){
s=s*a%1000;
}
if(s<100)cout<<0;
if(s<10) cout<<0;
cout<<s;
return 0;
}
A1085
#include<iostream>
using namespace std;
int main(){
double h;
cin>>h;
cout<<3*h-h/256<<endl;
cout<<h/1024<<endl;
return 0;
}
A1110
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a[100000],n,x,ans=0;
cin>>n;
for (int i=1;i<=n;i++){
cin>>a[i];
}
cin>>x;
for(int i=1;i<=n;i++){
cin>>a[i];
if(a[i]==x){
ans=i;
break;
}
}
cout<<ans;
return 0;
}
A1107
#include<stdio.h>
int main()
{
int L, M, i, j, n;
int a[10001], b[10001];
scanf("%d %d",&L, &M); //输入L和M
n = M*2; //循环输入b数组0~n的数据
for(i=0; i<n; i+=2)
{
scanf("%d %d", &b[i], &b[i+1]);
}
for(i=0; i<=L; i++) //循环给a数组L个元素赋值
{
a[i] = i;
}
int r, s;
for(i=0; i<n; i+=2) //遍历访问数组b的各个区间
{
r = b[i]; //区间起始点
s = b[i+1]; //区间终点
for(j=r; j<=s; j++) //把数组b各个区间内元素在数组a中映射为0
{
a[j] = -1;
}
}
int k=0; //k用来统计不是0的个数,k赋值为1(数组a中原本包含一个0,此时加上)
for(i=0; i<=L; i++)
{
if(a[i] != -1)
{
k++; //用来统计非0的个数,即不在数组b区间内的数的个数
}
}
printf("%d", k);
return 0;
}
A1118
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int x[N],y[N],xlen[N],ylen[N];
int main()
{
int n; cin>>n;
for(int i=1;i<=n;i++){
cin>>x[i]>>y[i]>>xlen[i]>>ylen[i];
}
int px,py; cin>>px>>py;
int ans=-1;
for(int i=1;i<=n;i++){
if(px>=x[i] && px<=x[i]+xlen[i] && py>=y[i] && py<=y[i]+ylen[i])
ans = i;
}
cout<<ans;
return 0;
}
A1124
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[10001][10001];
int b[10001][10001];
int ans[10001][10001];
int now;
int tot;
int main()
{
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
cin>>a[i][j];
}
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
cin>>b[i][j];
ans[i][j]=a[i][j]+b[i][j];
}
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
cout<<ans[i][j]<<" ";
}
cout<<endl;
}
return 0;
}