ACM 2453 Wrong Answer

注意车距2022-10-04 11:39:541条回答

ACM 2453 Wrong Answer
我的输出结果正确,他却一直报错……
Description
As we known,data stored in the computers is in binary form.The problem we discuss now is about the positive integers and its binary form.
Given a positive integer I,you task is to find out an integer J,which is the minimum integer greater than I,and the number of '1's in whose binary form is the same as that in the binary form of I.
For example,if "78" is given,we can write out its binary form,"1001110".This binary form has 4 '1's.The minimum integer,which is greater than "1001110" and also contains 4 '1's,is "1010011",i.e."83",so you should output "83".
Input
One integer per line,which is I (1

已提交,审核后显示!提交回复

共1条回复
kelisipp 共回答了18个问题 | 采纳率94.4%
#include
int Count_Num_One( int num )
{
x05int counter_one = 0;
x05while (num) {
x05x05if(num%2 == 1)
x05x05x05counter_one++;
x05x05num = num /2;
x05}
x05return counter_one;
}
int main(void)
{
x05int number,i;
x05int counter = 0;
x05int num_of_one = 0;
x05
x05while(scanf("%d",&number),number != 0)
x05{
x05x05/*
x05x05if(number100000)
x05x05{
x05x05x05continue;
x05x05}
x05x05*/
x05x05num_of_one = Count_Num_One(number);
x05x05for(number=number+1;;number++)
x05x05{
x05x05x05if(Count_Num_One(number)==num_of_one)
x05x05x05{
x05x05x05x05printf("%dn",number);
x05x05x05x05break;
x05x05x05}
x05x05}
x05}
x05return 0;
}
1年前

相关推荐

Wrong Answer?我是菜鸟,我怕谁Time Limit:2000/1000 MS (Java/Others) M
Wrong Answer?
我是菜鸟,我怕谁
Time Limit:2000/1000 MS (Java/Others) Memory Limit:32768/32768 K (Java/Others)
Total Submission(s):2507 Accepted Submission(s):1399
Problem Description
lin2144是一只小菜鸟,都是笨鸟先飞,lin2144想来个菜鸟先飞,他从0点出发
一开始的飞行速度为1m/s,每过一个单位时间lin2144的飞行速度比上一个单位时间的飞行速度快2m/s,问n (0 < n < 10^5)个单位时间之后lin2144飞了多远?
Input
输入一个T表示为有几组数据
每组数据输入一个n,表示lin2144飞行的时间.
Output
输出lin2144飞行了多远,因为数字很大,所以对10000取模.
Sample Input
2
1
2
Sample Output
1
4
#include
void main()
{
x05int n,i,j=0;
x05scanf("%d",&n);
x05while(j
邻家男孩X1年前1
孤意与深情 共回答了15个问题 | 采纳率93.3%
#include
int main()
{
int n,i,j=0;
scanf("%d",&n);
while(j
hdu 为什么总是wrong answer哪
hdu 为什么总是wrong answer哪
#include
#include
int main()
{int n,i,a[100],c[100],b[100],d[100];
double m[100];
scanf("%d",&n);
for(i=0;i
大洗脚盆1年前1
缘深缘浅16 共回答了20个问题 | 采纳率95%
其实是可以读一组输出一组的,没有必要读完再统一输出
#include
#include
int main()
{
x05int n,i;
x05double a[100],c[100],b[100],d[100]; // 改用实数
x05double m[100];
x05scanf("%d",&n);
x05for(i=0;i
但是我写的就是wrong answer.
但是我写的就是wrong answer.
I have a very simple problem for you.Given two integers A and B,your job is to calculate the Sum of A + B.
Input
The first line of the input contains an integer T(1line;
while((line--)&&cin>>A>>B)
{
cout
bgt51年前1
流星雪夜 共回答了23个问题 | 采纳率87%
#include
#include
using namespace std;
#define max 1010
int main()
{
int line,a[max]={0},b[max]={0},c[max]={0},l1,l2,l3,i,j=1,flag;
char A[max],B[max];
cin>>line;
while((line--)&&cin>>A>>B)
{
cout
一道化学计算题.我算得答案是c,wrong answer~
一道化学计算题.我算得答案是c,wrong answer~
用12.5g含杂质碳20%的石灰石与含8g HCl 的稀盐酸反应制 CO2 气体(杂质不参与反应,盐酸的挥发忽略不计),则收集到的 CO2 的质量为
A、5.5g
B、4.4g
C、4.8g
D、4.2g
flztyjs1年前3
S_L_Zero 共回答了21个问题 | 采纳率90.5%
计算可得 CaCO3 质量为 10.0g
HCl 过量
则 CaCO3 + 2 HCl = CaCl2 + H2O + CO2
10.0g 4.4g
故选B
hdu2044为什么wrong answer 啊.
hdu2044为什么wrong answer 啊.
#include
using namespace std;
int main()
{
int n,i,a,b,j;
cin>>n;
for(i=1;i>a>>b;
double m[55];
m[1]=m[2]=1;
for(j=3;j
潜水专用B1年前1
续接受报 共回答了15个问题 | 采纳率100%
类型错了,m这个数组用__int64类型就行了
不过C++的输出流n;
for(i=1;i>a>>b;
__int64 m[55];
m[1]=m[2]=1;
for(j=3;j
一个ACM的A+B问题因为我是初学者,想试试ACM,但是A+B就wrong answer了Problem Descrip
一个ACM的A+B问题
因为我是初学者,想试试ACM,但是A+B就wrong answer了
Problem Description
Calculate A + B .
Input
Each line will contain two integers A and B .Process to end of file.
Output
For each case,output A + B in one line.
Sample Input
1 1
Sample Output
2
下面是我写的
# include
int main()
{
int a,b,sum;
scanf("%d,%d",&a,&b);
sum=a+b;
printf("%d",sum);
return 0;
}
为什么会wrong呢,那该怎么写呢,用C写
skygirl691年前2
blackstorm 共回答了16个问题 | 采纳率93.8%
# include
int main()
{
int a,b,sum;
scanf("%d%d",&a,&b);//去掉逗号,题目中是以空格分开的
sum=a+b;
printf("%d",sum);
return 0;
}
acm简单的问题一直wrong answer
acm简单的问题一直wrong answer
有一些三个整数构成的整数群,它的结构是:第一行整数N表示后面有N个几个整数群,每个整数群由三个整数组成.尝试用+、-、×、/(整除)来凑前两个数的计算结果,以图与第三个整数相等.如果能凑到相等,则输出该表达式,否则,输出None.输入将保证若表达式存在,则一定唯一.
Sample Input:
5
123 1234 10
12 34 22
12 12 24
5678910 7 56789
9 4 2
Sample Output:
1234/123=10
34-12=22
12+12=24
None
9/4=2
程序如下
#include
#include
#include
#include
using namespace std;
string convertToString(double x)
{
x05ostringstream o;
x05if(on;
x05for(int j=0;j>a>>b>>c;
x05
x05x05if(a+b==c)
x05x05{
x05x05x05s=convertToString(a)+"+"+convertToString(b)+"="+convertToString(c);
x05x05x05v.push_back(s);
x05x05x05continue;
x05x05}
x05x05if(a-b==c||b-a==c)
x05x05{
s=convertToString(a>b?a:b)+"-"+convertToString(b>a?a:b)+"="+convertToString(c);
x05x05x05v.push_back(s);
x05x05x05continue;
x05x05}
if(a*b==c)
x05x05{
s=convertToString(a)+"*"+convertToString(b)+"="+convertToString(c);
x05x05x05v.push_back(s);
x05x05x05continue;
x05x05}
x05x05if(a/b==c||b/a==c)
x05x05{
s=convertToString(a>b?a:b)+"/"+convertToString(b>a?a:b)+"="+convertToString(c);
x05x05x05v.push_back(s);
x05x05x05continue;
x05x05}
x05x05else
x05x05x05v.push_back("None");
x05}
x05for(int i=0;i
zhouling1年前1
喝西柚汁的猫 共回答了24个问题 | 采纳率79.2%
没考虑右边数是负数的情况,比如12-34=-22 -6/3=-2
解决方法就是if(a/b==c||b/a==c) 还有if(a-b==c||b-a==c) 不要写成这种或的形式 直接判断到底是a-b=c还是b-a=c,然后输出即可
另外不用把所有的结果存起来一起输出.得到一个结果就cout输出一个结果即可.这样避免很多麻烦.
acm题,wrong answer,为什么?
acm题,wrong answer,为什么?
Description
James得到了一堆有趣的硬币,于是决定用这些硬币跟朋友们玩个小游戏.在一个N行M列的表格上,每一个第i行第j列的格子上都放有一枚James的硬币,抛该硬币正面朝上的概率为Pij,所有抛硬币事件两两之间是相互独立的.
现在,玩家在M列硬币中,从每一列里各选择1枚,共M枚,构成一组.如此重复选择N组出来,且保证被选择过的硬币不能再选.选好组之后,每组的M枚硬币各抛一次,如果都是正面朝上,则该组胜利,总分赢得1分;否则该组失败,总分不加也不减.请问,如果让你自行选择硬币的分组,游戏总得分的数学期望的最大值是多少?
Input
输入有多组数据.每组数据第一行为N和M,1≤N≤100,1≤M≤10,以空格分隔.接下来有N行,每行M个小数,表示表格中对应的Pij.
输入以N=M=0结束,这组数据不输出结果.
Output
对于每组数据,输出对应游戏总得分的数学期望的最大值,四舍五入精确至4位小数.每组数据的输出占一行.
代码:
#include
#include
#include
#define N 101
#define M 11
int compare(const void *a,const void *b)
{
x05return *(int*)b-*(int*)a;
}//
int main()
{
x05float a[M][N]={};
x05int m=0,
x05x05n=0;
x05int i,j;
x05float sum,Sum;
x05while(scanf("%d %d",&n,&m) = EOF && m = 0 && n = 0)//***有可能会出错 ***
x05{//大循环
x05x05sum=1;Sum=0;//初始化
x05x05memset(a,0,sizeof(a));
x05x05for(j=0;j
zhishipx1年前1
xclwp 共回答了29个问题 | 采纳率89.7%
主要问题出在比较函数上#include
#include
#include
#define N 101
#define M 11
// 需要直接比较double,而不能返回差值
int compare(const void *a, const void *b)
{
double* da = (double*)a;
double* db = (double*)b;
if (*da > *db) {
return -1;
}
else if (*db > *da) {
return 1;
}
return 0;
}//
int main()
{
double a[M][N];
int m = 0,
n = 0;
int i, j;
double sum, Sum;
while (scanf("%d %d", n, m) != EOF m != 0 n != 0)//***有可能会出错 ***
{//大循环
sum = 1; Sum = 0;//初始化
for (j = 0; jfor (i = 0; i < m; i++)
scanf("%lf", a[i][j]);//输入
for (i = 1; i <= m; i++)
qsort(a[i], m, sizeof(double), compare);//从大到小排序
for (j = 0; j{
for (i = 1; i <= m; i++)
sum *= a[i][j];
Sum += sum;
sum = 1;//初始化
}
printf("%.4fn", Sum);
}//大循环
}
acm题为什么wrong answer啊
acm题为什么wrong answer啊
John von Neumann, b. Dec. 28, 1903, d. Feb. 8, 1957, was a Hungarian-American mathematician who made important contributions to the foundations of mathematics, logic, quantum physics, meteorology, science, computers, and game theory. He was noted for a phenomenal memory and the speed with which he absorbed ideas and solved problems. In 1925 he received a B.S. diploma in chemical engineering from Zurich Institute and in 1926 a Ph.D. in mathematics from the University of Budapest. His Ph.D. dissertation on set theory was an important contribution to the subject. At the age of 20, von Neumann proposed a new definition of ordinal numbers that was universally adopted. While still in his twenties, he made many contributions in both pure and applied mathematics that established him as a mathematician of unusual depth. His Mathematical Foundations of Quantum Mechanics (1932) built a solid framework for the new scientific discipline. During this time he also proved the mini-max theorem of GAME THEORY. He gradually expanded his work in game theory, and with coauthor Oskar Morgenstern he wrote Theory of Games and Economic Behavior (1944).
There are some numbers which can be expressed by the sum of factorials. For example 9, 9 = 1! + 2! + 3! Dr. von Neumann was very interested in such numbers. So, he gives you a number n, and wants you to tell him whether or not the number can be expressed by the sum of some factorials.
Well, it's just a piece of cake. For a given n, you'll check if there are some xi, and let n equal to SUM{xi!} (1 ≤ i ≤ t, t ≥ 1, xi ≥ 0, xi = xj iff. i = j). If the answer is yes, say "YES"; otherwise, print out "NO".
Input
You will get several non-negative integer n (n ≤ 1,000,000) from input. Each one is in a line by itself.
The input is terminated by a line with a negative integer.
Output
For each n, you should print exactly one word ("YES" or "NO") in a single line. No extra spaces are allowed.
Sample Input
9
-1
Sample Output
YES
#include
using namespace std;
int main()
{
int m,n,a[9]={1,2,6,24,120,720,5040,40320,362880},b=0,c=0,d=0,e=0,f=0;
while(n>=0&&cin>>n)
{

for(m=0;m
titi1983061年前1
xmal1007 共回答了17个问题 | 采纳率88.2%
7=1!+3!
这个数据你就不对
等等等 总是Wrong answer
等等等 总是Wrong answer
Description给出一个二维平面内的向量u(u1,u2),求它逆时针旋转x角度之后的向量v(v1,v2).
Input输入包括多组测试用例,通过EOF结束.每个测试用例包括一行,共三个数,分别为题目中的u1,u2,x.
Output对于每个测试用例输出一行,共两个数v1 v2,以空格隔开,保留到小数点后四位.
输入1 0 90
2 0 90
输出0.0000 1.0000
0.0000 1.0000
我的代码
#include
#include
#include
using namespace std;
int main()
{
while(!cin.eof())//这一行我上网查的
{
long double a,b,c;
cin>>a>>b>>c;
long double d = atan2(b,a);
long double e = d + c*3.141592653589/180;
long double l = sqrt(a*a+b*b);
long double a1,b1;
a1 = l * cos(e);
b1 = l * sin(e);
cout
0skrb1年前1
悔毁 共回答了19个问题 | 采纳率94.7%
你有没有考虑 u(0,0)的情况?
为什么一直是Wrong Answer啊,
为什么一直是Wrong Answer啊,
Description
There are some students’ grade records,in format of “name grade”.
In order to make the teacher to view and manage all the records easily,you are
asked to develop a program to sort the records first by grade (in descending
order),and second by name (in alphabetic
order).That means the sorted records will be from the highest grade to lowest
grade; and if two students have the same grade,whose name appeared earlier in
a dictionary will be shown earlier.
Input
8 grade records,one record on per line.
Only letters and digits appear in the name of a student (i.e.therewill be no space in a name).All grades are integers.
Output
The 8 sorted records,one record per line.
Sample Input
WangYi 90
LiMing 90
HuRui 50
ZhangLi 65
LiLei 80
ZhangFei 65
ZhaoSan 70
ChenZi 100
Sample Output
ChenZi 100
LiMing 90
WangYi 90
LiLei 80
ZhaoSan 70
ZhangFei 65
ZhangLi 65
HuRui 50
#include
#include
int main()
{
typedef struct
{
char name[200];
int grade;
}Mess;
Mess a[8];
int t,i,j;
char q[200],s[200];
for(i=0;i
dsf452411年前1
合久必婚 共回答了17个问题 | 采纳率88.2%
算法错误.
for(i=0;i0)
{
strcpy(s,a[i].name);
strcpy(a[i].name,a[i+1].name);
strcpy(a[i+1].name,s);
}
没有正确排序.一层循环不是排序,只是交换邻位,应该两层嵌套循环,而且最好放在上面的那个两层循环里面更快.
而且正常做法,直接使用algorithm库的sort函数就可以了,没必要自己写排序.