藍橋入門訓練系列
用于熟悉藍橋杯輸入輸出的一些水題,提供個人解法讓各位沒直接通過的同學參考一下
試題 入門訓練 A+B問題
#include<iostream>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
cout<<a+b<<endl;
return 0;
}
試題 入門訓練 序列求和
#include<iostream>
using namespace std;
int main(){
long long n;
cin>>n;
n=(1+n)*n/2;
cout<<n;
return 0;
}
試題 入門訓練 圓的面積
#include<cstdio>
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
using namespace std;
int main(){
int r=0;
double area=0;
cin>>r;
area=M_PI*pow(r,2);
printf("%.7f",area);
return 0;
}
試題 入門訓練 Fibonacci數列
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
int a=1,b=1,n=0,temp=0;
cin>>n;
if(n==1||n==2){
cout<<1<<endl;
return 0;
}
while(n>2){
temp=(a+b)%10007;
swap(a,b);
swap(b,temp);
n--;
}
cout<<b<<endl;
return 0;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/206289.html
標籤:其他
上一篇:藍橋杯:試題 基礎練習 階乘計算
