結果
| 問題 |
No.2043 Ohuton and Makura
|
| コンテスト | |
| ユーザー |
merlin
|
| 提出日時 | 2022-08-19 22:01:43 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 82 ms / 2,000 ms |
| コード長 | 985 bytes |
| コンパイル時間 | 1,977 ms |
| コンパイル使用メモリ | 74,440 KB |
| 実行使用メモリ | 38,056 KB |
| 最終ジャッジ日時 | 2024-10-08 08:42:19 |
| 合計ジャッジ時間 | 4,118 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
ソースコード
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;
}
}
merlin