simp1eton's blog

By simp1eton, 15 years ago, In English
Hi,

I am new to Codeforce. Hello everyone!

I just coded for A - Threatre Square from Beta Round #1 and got the following error. Can someone tell me why?

The first problem is - I cannot use scanf and printf when I use #include <iostream>

The second problem is - Why is it that the first code does not work while the second one does?

First Code:
#include <iostream>
#include <cstdio>
using namespace std;

long long int N,M,A;

int main(){
    scanf("%lld%lld%lld", &N,&M,&A);
    printf("%lld\n", ((N+A-1ll)/A)*((M+A-1ll)/A));
}

// The first code failed at test case 16.

Second Code:
#include <iostream>
#include <cstdio>
using namespace std;

long long int N,M,A;

int main(){
    cin>>N>>M>>A;       //The only thing I did is to change all scanf and printf into cin and cout
    cout<<((N+A-1)/A)*((M+A-1)/A)<<endl;
}

//The second code passed all testcases.

Thanks a lot in advance.
  • Vote: I like it
  • 0
  • Vote: I do not like it

15 years ago, # |
  Vote: I like it +13 Vote: I do not like it
Answer for first question: scanf and printf are from stdio.h, not iostream.h

Second: %lld doesn't work in MinGW. Either use %I64d instead, or choose Visual C++ instead of MinGW when you submit.