Doubt regarding long long int and modulus operator

Does the modulus operator(%) work with long long int .

I did a prob in which, the if condition is only reached ,if i use int and not long long int.

it works fine if i use int.

{i used long long a i read some where that using long long always reduces chances of overflow}

thanks in advance for your time!!:blush::blush:

NO, IT WORKING WITH LONG LONG ALSO

BUT it is not working in the above code :thinking:
thanks for ur time!

https://www.codechef.com/viewsolution/30790286

i am sorry somehow when i pressed the link i had given it went back to default code.
i now tried saving my code in that link.
It still isn’t working if i give long long to n and k.
Specifically it works if i give long long to only temp and counter
and not if i give it to n and k

thanks for your patience!!:blush:

this is the code

#include<bits/stdc++.h>

int main()
{
     long long int n,k;
     long long int temp,counter=0;
    scanf("%d %d",&n,&k);
    printf("%d %d",n,k);
    while(n--)
    {
        scanf("%d",&temp);
        printf("%d \n",temp);
        if((temp%k)==0)
         {  printf("reached");
             counter++;
         }
        
    }
    printf("%d\n",counter);
    return 0;
}

You are declaring long long int.

But scanning and printing int.
Format specifier for long long is %lld.

ios_base::sync_with_stdio(false);
cin.tie(NULL);

use fast input , output
with cin , cout

ohhh thanks a lot sir!!:sweat_smile::sweat_smile::sweat_smile:.
i recently learned scanf and printf( i use c++) when i tried faster input methods.
sorry for my mistake
thanks again.!

Ok thanks a lot sir for your help.
I will learn how to implement fast input in c++ itself.
thanks again!:blush: