1.
#include <iostream>
#define MAX 1000000
#define a 10007
using namespace std;
int n, i, F[MAX];
int main(){
while (cin >> n) {
F[1] = 1;
F[2] = 1;
for (i = 3; i <= n; ++i)
F[i] = (F[i - 1] + F[i - 2]) % a;
cout << F[n]<<endl;
}
return 0;
}
2.
#include <iostream>
#include <iomanip>
#define PI 3.14159265358979323846
using namespace std;
int main()
{
int r;
double s;
cin >> r;
s = PI*r*r;
cout << setiosflags(ios::fixed)<<setprecision(7)<<s;
//setiosflags(ios::fixed)主要是将流的格式设置为:fixed(将一个浮点表示为一个定点整数和小数点和小数部分的格式。然后setprecision(4)表示小数部分的精度为4位
return 0;
}
3.
#include <iostream>
using namespace std;
int main()
{
long long int n,sum;
while (cin >> n) {
if (n % 2 == 0) {
sum = (n / 2)*(1 + n);
cout << sum << endl;
}
else if (n % 2 != 0) {
sum = (((n - 1) / 2)*n) + n;
cout << sum << endl;
}
}
return 0;
}
4.
#include <iostream>
using namespace std;
int main(){
int a, b;
cin >> a >> b;
cout << a + b;
return 0;
}
蓝桥杯入门题
猜你喜欢
转载自blog.csdn.net/weixin_42964413/article/details/87880767
今日推荐
周排行