1481: Sister Wang
时间限制: 1 Sec 内存限制: 256 MB提交: 514 解决: 115
[ 提交][ 状态][ 讨论版]
题目描述
Do you know Sister Wang?
Sister Wang is goddess and many diaosi want to know her phone number. Sister Wang doesn’t tell them her number directly. She tells them a string, contains letters,
digits and symbols,but no blanks. And her phone number is in the string. Fushuai knows how to get the phone number. He delete the letters and symbols from the
string, so that he gets some digits, and then he sort the digits in ascending order. In this way, Fushuai succeeds in calling Sister Wang.
输入
There are several cases. Each cases contains a string L(1<= length(L)<=20).
输出
Output Sister Wang’s phont number.
样例输入
Sist1e2r3w4a5ng
样例输出
12345
提示
来源
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
char s[111];
string str;
while(~scanf("%s",s))
{
str="";
for(int i=0;s[i]!='\0';i++)
{
if(s[i]>='0'&&s[i]<='9')
str=str+s[i];
}
sort(str.begin(),str.end());
cout<<str<<endl;
}
return 0;
}
/**************************************************************
Problem: 1481
User: 1307122118
Language: C++
Result: 正确
Time:4 ms
Memory:1260 kb
****************************************************************/
1482: Christmas math gift
时间限制: 1 Sec 内存限制: 256 MB提交: 56 解决: 27
[ 提交][ 状态][ 讨论版]
题目描述
输入
输出
样例输入
2
3 3 3
0 0 0
样例输出
no solution
multiple solution
提示
来源
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<queue>
using
namespace
std;
int
main()
{
int
t,a,b,c;
int
del;
scanf
(
"%d"
,&t);
while
(t--)
{
scanf
(
"%d%d%d"
,&a,&b,&c);
if
(a==0)
{
if
(b==0)
{
if
(c==0)
{
printf
(
"multiple solution\n"
);
}
else
{
printf
(
"no solution\n"
);
}
}
else
{
printf
(
"one solution\n"
);
}
}
else
{
del=b*b-4*a*c;
if
(del<0)
{
printf
(
"no solution\n"
);
}
else
if
(del==0)
{
printf
(
"one solution\n"
);
}
else
{
printf
(
"multiple solution\n"
);
}
}
}
return
0;
}
/**************************************************************
Problem: 1482
User: 1307122118
Language: C++
Result: 正确
Time:0 ms
Memory:1252 kb
****************************************************************/
1483: Fushaui see movie
时间限制: 1 Sec 内存限制: 256 MB提交: 83 解决: 25
[ 提交][ 状态][ 讨论版]
题目描述
输入
输出
样例输入
2
5
1 2 2 4 4
5
2 3 4 5 1
样例输出
2
5
提示
来源
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<queue>
using namespace std;
int a[200005],f[200005];
int main()
{
int t,i,n,ans;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
a[i+n]=a[i];
}
f[0]=1;
ans=1;
for(i=1;i<2*n;i++)
{
if(a[i]>a[i-1])
{
f[i]=f[i-1]+1;
}
else
{
f[i]=1;
}
ans=max(ans,f[i]);
}
printf("%d\n",ans);
}
return 0;
}
1484: Hengheng eat noodles
时间限制: 1 Sec 内存限制: 256 MB提交: 15 解决: 12
[ 提交][ 状态][ 讨论版]
题目描述
As we all know,Hengheng(big cow),very look forward to meizi and he often declare that he want to find a meizi.As Hengheng’s admirer, Jiajia decides to help Hengheng to achieve his dream in Christmas Day. In this day, Jiajia asks Hengheng to eat noodles with a pretty meizi(don’t ask why Jiajia didn’t chase this pretty meizi). When eating noodles, Hengheng is so excited that he wants the qq of the meizi. However, a unlucky thing happen.The pretty meizi says she won’t give Hengheng her qq unless Hengheng can solve her question. Hengheng promise without hesition.The pretty meizi picks up a noodle and say with sexy voice, “We all know a noodle has two ends,and now I has n noodles, so there are 2*n ends at all. Out of interest,I will link these ends randomly,and then I wonder the mathematical expectation of the circle I could get.” Although Hengheng is big cow, he can’t wait to get the qq so he can’t think as long as he see the pretty. So he ask Jiajia to solve the problem for him. Luckily,after 1000 ms,Jiajia give the right answer. And Hengheng got the qq successfully. Now, if you are Jiajia, could solve the problem within 1000 ms and help Hengheng get the qq.
输入
The first line is a integer t,indicate the number of cases.(t<=10)
For each case follow,there is a integer n,imply the amount of noodles.(n<=10^6)
输出
For each case, print a double E,represent the mathematical expectation.(E retain 6 decimal)
样例输入
3
1
2
4
样例输出
1.000000
1.333333
1.676190
提示
来源
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
using
namespace
std;
double
e[1000001];
int
main()
{
int
t,i,n;
e[1]=1.000000;
for
(i=2;i<=1000001;i++)
{
e[i]=(e[i-1]+1.0)/(2*i-1)+e[i-1]*(2*i-2)/(2*i-1);
}
scanf
(
"%d"
,&t);
while
(t--)
{
scanf
(
"%d"
,&n);
printf
(
"%lf\n"
,e[n]);
}
return
0;
}
/**************************************************************
Problem: 1484
User: 1307122118
Language: C++
Result: 正确
Time:119 ms
Memory:9064 kb
****************************************************************/
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
using
namespace
std;
double
e[1000001];
int
main()
{
int
t,i,n;
e[1]=1.000000;
for
(i=2;i<=1000001;i++)
{
e[i]=(e[i-1]+1.0)/(2*i-1)+e[i-1]*(2*i-2)/(2*i-1);
}
scanf
(
"%d"
,&t);
while
(t--)
{
scanf
(
"%d"
,&n);
printf
(
"%lf\n"
,e[n]);
}
return
0;
}
/**************************************************************
Problem: 1484
User: 1307122118
Language: C++
Result: 正确
Time:119 ms
Memory:9064 kb
****************************************************************/
|