Home > Back-end >  To solve the int type is can not be caculated directly and long long, thank you!
To solve the int type is can not be caculated directly and long long, thank you!

Time:10-04

This problem is arithmetic progression, topic request input data to ensure & lt;=10 power 6, so think of with long long, below in that way before but didn't pass,
Then guess may be 24 row (a sum that row) int type data and long long type can not be directly calculated, and then change to the code above (notes) is passed, but the principle is not very good,


Want to ask next int data directly, and can have cast floating-point calculations,, but not data only and long long long long type calculation??
O bosses, thank you!!!!!!

CodePudding user response:

The computer is how many?

Not 16 int enough

CodePudding user response:

The
reference 1 floor? Victor.?? Response:
how much is a computer?

Not 16 int enough

64 - bit, but I use int turn it in in los GuTong, however, I think the first and the second and the number of items are & lt;=10 ^ 6, the end result can be used long long, it is only long long is not very good is unable to be calculated and int

CodePudding user response:

Normally you can ah

Are plastic

CodePudding user response:

The
reference 3 floor? Victor.?? Response:
normally can!

Are plastic

I don't know why.. I just input, 45454, 789789, 45454, for example, use the following code is the code, use the above code can be calculated, whether data will be lost or something... Like float double??

CodePudding user response:

Save the int variable overflow, probably truncated to the sum, so data is wrong,
Sum=(int64) (XXXX);

CodePudding user response:

45454 789789 45454

The three number

Calculate a [2] the seams (a [2] is int)

CodePudding user response:

(int64) [0] a similar turn better

CodePudding user response:

# include & lt; stdio.h>

Int main ()
{
Long long int a, b, n, d.
Long long int sum;
The scanf (" % LLD % % LLD LLD ", & amp; A, & amp; B, & amp; N);
D=b - a;
The sum a +=n * n * (n - 1) * d/2;
Printf (" % LLD \ n ", sum);
Return 0;
}

It can be, he single-handedly

CodePudding user response:

Feel your problems out on the calculation of a [2] the

A [2]=(a [1] - [0] a) * (n - 1) + a, [0].

A [2] is int cross-border

You can replace array with 3 digits

Put a [2] corresponding with long long

A [0], a [1] with int

Verify

CodePudding user response:

The
reference 8 floor? Victor.?? Response:
# include & lt; stdio.h>

Int main ()
{
Long long int a, b, n, d.
Long long int sum;
The scanf (" % LLD % % LLD LLD ", & amp; A, & amp; B, & amp; N);
D=b - a;
The sum a +=n * n * (n - 1) * d/2;
Printf (" % LLD \ n ", sum);
Return 0;
}

Can such, make he

Is all long long of, in the valley of los passed on

CodePudding user response:

The
references 9 floor? Victor.?? Response:
feel your problem on the calculation of a [2]

A [2]=(a [1] - [0] a) * (n - 1) + a, [0].

A [2] is int cross-border

You can replace array with 3 digits

Put a [2] corresponding with long long

A [0], a [1] with int

Verify

Yes!!!!! I didn't understand this!!!!!
I was also set up a long long temp, temp as at the end of the term, want to ask next sum=(temp + a [0]) * n/2; This is done automatically converts a [0] into long long, or because a relatively small [0] not data is missing, anyway I do this is through

CodePudding user response:

Should be low high

Int - & gt; Long long
  • Related