10055 - Hashmat the Brave Warrior
Moderator: Board moderators
I think that in MSVC, long data type is also 64-bit. This is not true for the GNU C++ compiler.
BTW, I have a big problem when using C standard IO functions to print out the values of long long int variables.
For example.
[cpp]#include <stdio.h>
int main() {
printf("%lld\n", 2147483648LL); // 2147483648 overflows int
return 0;
}[/cpp]
Output: -2147483648
I have this problem when compiling with MinGW compiler and Cygwin compiler.
Can anyone tell me how my problem can be resolved without using standard C++ I/O streams? Thank you.
BTW, I have a big problem when using C standard IO functions to print out the values of long long int variables.
For example.
[cpp]#include <stdio.h>
int main() {
printf("%lld\n", 2147483648LL); // 2147483648 overflows int
return 0;
}[/cpp]
Output: -2147483648
I have this problem when compiling with MinGW compiler and Cygwin compiler.
Can anyone tell me how my problem can be resolved without using standard C++ I/O streams? Thank you.
Long Long
To incin:
You mean that is no way to use Long Long?
[cpp]long long i;[/cpp]
BTW, I suggest you use Dev C++. It uses the Mingw/GCC 3.2 Compiler.
http://www.bloodshed.net/dev/devcpp.html
And did you get Accepted using Double?
-------------------------------------------------------------
To: Lim Zhuomin
Maybe the solution is to use cout??
BTW, you are using cygwin g++ compiler?
To my knowledge, cygwin eats up lots of resources on windows.
Ming Han
You mean that is no way to use Long Long?
[cpp]long long i;[/cpp]
BTW, I suggest you use Dev C++. It uses the Mingw/GCC 3.2 Compiler.
http://www.bloodshed.net/dev/devcpp.html
And did you get Accepted using Double?
-------------------------------------------------------------
To: Lim Zhuomin
Maybe the solution is to use cout??
BTW, you are using cygwin g++ compiler?
To my knowledge, cygwin eats up lots of resources on windows.
Ming Han
:: HanWorks ::
-
- Experienced poster
- Posts: 151
- Joined: Wed Aug 21, 2002 12:07 am
- Location: Seoul, Korea
- Contact:
You CAN use double for this problem
1. Simply try using %.0lf instead of %.0f, then you'll get Accepted.
2. In Visual C++, you can use __int64. And, I believe that GCC's printf and scanfs don't support long long int.. (Read that from a problem statement in this site)
add by edit:
Yes, I found it.. It was problem 10392. http://acm.uva.es/p/v103/10392.html
I wonder if it is trustable..
2. In Visual C++, you can use __int64. And, I believe that GCC's printf and scanfs don't support long long int.. (Read that from a problem statement in this site)
add by edit:
Yes, I found it.. It was problem 10392. http://acm.uva.es/p/v103/10392.html
I wonder if it is trustable..
-
- New poster
- Posts: 6
- Joined: Wed Jan 22, 2003 9:19 pm
- Contact:
WA
I read all the threads on this problem. I still can't figure out why I am getting WA. Could u please help me out ?
Here is my code.
#include<iostream.h>
int main()
{
unsigned long long int a,b,tempa,tempb;
while(!cin.eof())
{
cin>>a>>b;
if(a > b)
tempa=a-b;
else
tempa=b-a;
cout<<tempa;
}
return 0;
}
TheChaosHacker
Here is my code.
#include<iostream.h>
int main()
{
unsigned long long int a,b,tempa,tempb;
while(!cin.eof())
{
cin>>a>>b;
if(a > b)
tempa=a-b;
else
tempa=b-a;
cout<<tempa;
}
return 0;
}
TheChaosHacker
-
- New poster
- Posts: 6
- Joined: Wed Jan 22, 2003 9:19 pm
- Contact:
Accepted
Thanx !
I changed those two lines and it worked. What was going wrong ?
TheChaosHacker
I changed those two lines and it worked. What was going wrong ?
TheChaosHacker
-
- Experienced poster
- Posts: 192
- Joined: Sat Nov 30, 2002 5:14 am
Try to use long long integer instead of using integer
Code: Select all
While (scanf ("%lld %lld", &a, &b) == 2) {
}
10055(W.A)
I get W.A
Anyone can help me
[cpp]#include<stdio.h>
#include<string.h>
main()
{
char in1[100000],in2[100000];
int n1=0,n2=0,ans[100000],i=0,i1=0,count=0,tr=0,carry=0;
scanf("%s%s",in1,in2);
n1=strlen(in1);
n2=strlen(in2);
count=n2;
i1=n2;
n2--;
n1--;
for(count=count-1;count>=0;count--)
{
if(n1>=0)
ans[count]=in2[n2]-in1[n1]-carry;
else
ans[count]=in2[n2]-carry-'0';
carry=0;
if(ans[count]<0)
{
carry=1;
ans[count]=10+ans[count];
}
n1--;
n2--;
}
for(i=0;i<i1;i++)
{
if(ans==0||ans==48)
{
if(tr!=0)
{
printf("%d",ans);
tr++;
}
}
else
{
printf("%d",ans);
tr++;
}
}
printf("\n");
tr=0;
}[/cpp]
Anyone can help me
[cpp]#include<stdio.h>
#include<string.h>
main()
{
char in1[100000],in2[100000];
int n1=0,n2=0,ans[100000],i=0,i1=0,count=0,tr=0,carry=0;
scanf("%s%s",in1,in2);
n1=strlen(in1);
n2=strlen(in2);
count=n2;
i1=n2;
n2--;
n1--;
for(count=count-1;count>=0;count--)
{
if(n1>=0)
ans[count]=in2[n2]-in1[n1]-carry;
else
ans[count]=in2[n2]-carry-'0';
carry=0;
if(ans[count]<0)
{
carry=1;
ans[count]=10+ans[count];
}
n1--;
n2--;
}
for(i=0;i<i1;i++)
{
if(ans==0||ans==48)
{
if(tr!=0)
{
printf("%d",ans);
tr++;
}
}
else
{
printf("%d",ans);
tr++;
}
}
printf("\n");
tr=0;
}[/cpp]
Last edited by lendlice on Sun Mar 16, 2003 4:20 am, edited 2 times in total.
OK, if you want to use array for this problem, you have great risk. I said to you before, for this problem the result is |in2-in1|, your program cannot solve this:
your output:
your second and last output are wrong! true output for they are 100 and 0, and for your input must be:
while(scanf("%s %s",in1,in2)==2){
...
}
you can solve this with your algo, but you must add one algorithm at the first your program until you declarate input. they are:
if(in1>in2) you must swap they before begin the proses. (you must keep this in your mind "in1 and in2, they are not string, but numbers").
hope this will be help.
Code: Select all
100 200
200 100
555 555
Code: Select all
100
900
blank line
while(scanf("%s %s",in1,in2)==2){
...
}
you can solve this with your algo, but you must add one algorithm at the first your program until you declarate input. they are:
if(in1>in2) you must swap they before begin the proses. (you must keep this in your mind "in1 and in2, they are not string, but numbers").
hope this will be help.
