結果

問題 No.2043 Ohuton and Makura
ユーザー merlinmerlin
提出日時 2022-08-19 22:01:43
言語 Java21
(openjdk 21)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 985 bytes
コンパイル時間 2,380 ms
コンパイル使用メモリ 73,748 KB
実行使用メモリ 38,092 KB
最終ジャッジ日時 2024-04-17 00:44:05
合計ジャッジ時間 6,349 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
36,872 KB
testcase_01 AC 60 ms
37,160 KB
testcase_02 AC 75 ms
37,536 KB
testcase_03 AC 62 ms
36,640 KB
testcase_04 AC 87 ms
38,068 KB
testcase_05 AC 89 ms
38,092 KB
testcase_06 AC 69 ms
37,104 KB
testcase_07 AC 88 ms
37,972 KB
testcase_08 AC 70 ms
37,024 KB
testcase_09 AC 75 ms
37,872 KB
testcase_10 AC 87 ms
38,024 KB
testcase_11 AC 94 ms
37,944 KB
testcase_12 AC 60 ms
36,948 KB
testcase_13 AC 59 ms
36,536 KB
testcase_14 AC 60 ms
37,036 KB
testcase_15 AC 60 ms
36,936 KB
testcase_16 AC 60 ms
36,548 KB
testcase_17 AC 92 ms
37,788 KB
testcase_18 AC 60 ms
36,548 KB
testcase_19 AC 88 ms
37,976 KB
testcase_20 AC 89 ms
38,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        String s[]=bu.readLine().split(" ");
        int n=Integer.parseInt(s[0]),m=Integer.parseInt(s[1]),area=Integer.parseInt(s[2]);
        long ans=0;
        for(int i=1;i<=area;i++)
        {
            long hor=n+1-i; //number of rows where we can place this
            if(hor<=0) break;
            //we need to multiply this with m+1-1 + m+1-2 + m+1-3 + ...+ m+1-breadth (consider only +ve values)
            //we need to make sure the cells covd is less area, so consider breadth
            int breadth=area/i, right=Math.max(0,m-breadth);
            long vsum=sum(m)-sum(right);
            ans+=hor*vsum;
        }
        System.out.println(ans);
    }

    static long sum(int n)
    {
        return 1l*n*(n+1)/2;
    }
}
0