2018蓝桥杯省赛java_蓝桥杯2018年A组省赛
1.分數
1/1 + 1/2 + 1/4 + 1/8 + 1/16 + …
每項是前一項的一半,如果一共有20項,
求這個和是多少,結果用分數表示出來。
類似:
3/2
當然,這只是加了前2項而已。分子分母要求互質。
#include
using namespace std;
#define REP(i,n) for(int i=0;i
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
//#define LOCAL
int main(){
#ifdef LOCAL
freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
#endif // LOCAL
long x=pow(2,19);
printf("%d/%d",x+x-1,x);
return 0;
}
3 .乘積尾零
標題:乘積尾零
如下的10行數據,每行有10個整數,請你求出它們的乘積的末尾有多少個零?
#include
using namespace std;
int main()
{
freopen("in.txt","r",stdin);
int sum2 = 0,sum5 = 0,temp;
while(cin >> temp)
{
while(temp%5==0)
{
temp/=5;
sum5++;
}
}
cout << sum5;
}
4. 第幾個幸運數
到x星球旅行的游客都被發給一個整數,作為游客編號。
x星的國王有個怪癖,他只喜歡數字3,5和7。
國王規定,游客的編號如果只含有因子:3,5,7,就可以獲得一份獎品。
我們來看前10個幸運數字是:
3 5 7 9 15 21 25 27 35 45
因而第11個幸運數字是:49
小明領到了一個幸運數字 59084709587505,他去領獎的時候,人家要求他準確地說出這是第幾個幸運數字,否則領不到獎品。
請你幫小明計算一下,59084709587505是第幾個幸運數字。
需要提交的是一個整數,請不要填寫任何多余內容。
#include
#include
using namespace std;
int main()
{
freopen("out.txt","w",stdout);
__int64 temp = 59084709587505ll,cos = 0;
for(int i = 0;i < 30;i++)
{
for(int j = 0;j < 30;j++)
{
for(int k = 0;k < 30;k++)
{
long double c1 = (pow(3.0,i)*pow(5.0,j)*pow(7.0,k));
if(c1<=temp)
{
if(i == 15&&j==1&&k==7)
//cout << fixed<
cout << "c1: "<< fixed <
cos++;
}
}
}
}
cout << cos << endl;
}
總結
以上是生活随笔為你收集整理的2018蓝桥杯省赛java_蓝桥杯2018年A组省赛的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python qt designer 重
- 下一篇: php调用函数的变量,从内PHP函数调用