Блог пользователя simp1eton

Автор simp1eton, 14 лет назад, По-английски
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.
  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

14 лет назад, # |
  Проголосовать: нравится +13 Проголосовать: не нравится
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.