結果

問題 No.2324 Two Countries within UEC
ユーザー kusagame12
提出日時 2023-11-06 17:29:02
言語 Java
(openjdk 23)
結果
TLE  
実行時間 -
コード長 744 bytes
コンパイル時間 4,001 ms
コンパイル使用メモリ 73,788 KB
実行使用メモリ 52,240 KB
最終ジャッジ日時 2024-09-25 23:05:21
合計ジャッジ時間 10,641 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 2
other TLE * 1 -- * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int m = sc.nextInt();
        int p = sc.nextInt();
        int q = sc.nextInt();
       
        //int[] ans = new int[q];
        for (int i = 0; i < q ; i++){ 
            int x = sc.nextInt();
            int f = sc.nextInt();
            
            int cnt = 0;
            for (int j = 1; j <= m ; j++){ 
             
                if((x * j) % p == f){
                    cnt++;   
                }
                
            }
            
            System.out.println(cnt);
            
        }
         
    }
   
}

0