思路题
来源:互联网 发布:mac梦幻西游启动器 编辑:程序博客网 时间:2024/04/30 14:58
输入两个整数x, y, 求满足x<=a,b,c<=y的整数解的个数。
输入最多包含10组数据。每组数据包含两个整数x, y(1<=x,y<=108)。
对于每组数据,输出解的个数。
1 101 20123 456789
Case 1: 0Case 2: 2Case 3: 16
因为1000^3=10的9次方,所以数字不超过1000
代码:
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
int r=1;
int x,y;
while(~scanf("%d%d",&x,&y))
{
int ans=0;
for(int a=x;a<=1000&&a<=y;a++)
{
for(int b=x;b<=1000&&b<=y;b++)
{
int sum=a*a*a+b*b*b;
if(sum/10>=x&&sum/10<=y&&sum%10==3)
{
ans++;
}
}
}
printf("Case %d: %d\n",r++,ans);
}
}
2
Digital clock use 4 digits to express time, each digit is described by 3*3 characters (including”|”,”_”and” “).now given the current time, please tell us how can it be expressed by the digital clock.
Each case contains 4 integers in a line, separated by space.
Proceed to the end of file.
1 2 5 62 3 4 2
_ _ _ | _||_ |_ ||_ _||_| _ _ _ _| _||_| _||_ _| ||_
The digits showed by the digital clock are as follows: _ _ _ _ _ _ _ _ | _| _||_||_ |_ ||_||_|| | ||_ _| | _||_| ||_| _||_|
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
string s1[15]={" _ "," "," _ "," _ "," "," _ "," _ "," _ "," _ "," _ "};
string s2[15]={"| |"," |"," _|"," _|","|_|","|_ ","|_ "," |","|_|","|_|"};
string s3[15]={"|_|"," |","|_ "," _|"," |"," _|","|_|"," |","|_|"," _|"};
int main()
{
int a[5];
while(~scanf("%d%d%d%d",&a[0],&a[1],&a[2],&a[3]))
{
cout<<s1[a[0]]<<s1[a[1]]<<s1[a[2]]<<s1[a[3]]<<endl;
cout<<s2[a[0]]<<s2[a[1]]<<s2[a[2]]<<s2[a[3]]<<endl;
cout<<s3[a[0]]<<s3[a[1]]<<s3[a[2]]<<s3[a[3]]<<endl;
}
}
求n!的数的位数
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
int n;
int p;
while(~scanf("%d",&n))
{ double sum=0;
for(int i=1;i<=n;i++)
sum+=log10(double(i));
p=int(sum);
printf("%d\n",p+1);
}
}
- 思路题
- 思路题
- 思路题
- 思路题
- 作文185题思路
- hduDP题(思路)
- 练思路的题
- ZOJ 3327(思路题)
- HDU 4970 思路题
- HDU 5301 思路题
- 周赛 5 【思路题】
- POJ 1904 思路题
- nyoj 1809 思路题
- 思路!
- 思路
- 思路
- 思路
- 思路
- 【Linux学习笔记】八、关机重启命令
- sqlmap 用户手册(续)
- 如何免费使用数据挖掘软件RapidMiner
- Java ArrayList自动扩容
- Python+Selenium练习篇之15-在浏览器中新开一个tab
- 思路题
- String.valueOf() 和 toString的区别
- HDU 2018 母牛的故事(递推)
- 【OpenCV3】棋盘格角点检测与绘制——cv::findChessboardCorners()与cv::drawChessboardCorners()详解
- django中sqlite3的配置使用
- JAVA OOP 第三章多态3
- google quic 安装记录,附带资源文件地址
- ipcs和ipcrm命令
- 网络I/O模型---同步异步阻塞非阻塞之惑