2014年3月11日 星期二

Codeforces - 1A Theatre Square

The following program is my ACcepted code for Codeforces -1A.
It's a for everybody to learn and discuss.
If there is any mistake or comment, please let me know.  :D

此乃Codeforces 1A的AC code!
歡迎一同討論學習,如有錯誤與任何建議請留言 : )


a有可能是1 ,所以當長*寬時可能會超過int的範圍,要使用long long int
a could be 1 so the result maybe over the range of int. Then we use long long int.


//This program is for Codeforces 1A Theatre Square
//題目來源 Problem link: http://codeforces.com/problemset/problem/1/A

#include<stdio.h>

int main()
{
    int n, m, a;
 
    while(scanf("%d %d %d", &n, &m, &a) != EOF)
    {
        if( (n % a) != 0)   n = n/a + 1;
        else                n = n/a;
     
        if( (m % a) != 0)   m = m/a + 1;
        else                m = m/a;
     
        printf("%I64d\n", (long long)n * (long long)m);  
    }
    return 0;
}


Please feel free to use it after adding this blog as an reference. (http://autekroy.blogspot.tw) If there is any mistake or comment, please let me know. :D 

歡迎使用與分享任何內容,但請記得標示此部落格為出處。(http://autekroy.blogspot.tw/) 如果有發現任何的錯誤與建議請留言或跟我連絡。 : )

沒有留言:

張貼留言

請留下您的任何想法或建議!
Please leave any thought or comment!