1 solutions

  • 0
    @ 2025-11-5 20:06:35

    C :

    #include<stdio.h>
    
    int main()
    {
    	int c,n,m;
    	scanf("%d",&c);
    	while(c--)
    	{
    		scanf("%d%d",&n,&m);
    		printf(n%(m+1)?"first\n":"second\n");
    	}
    	return 0;
    }
    

    C++ :

    #include<stdio.h>
    
    int main()
    {
    	int c,n,m;
    	scanf("%d",&c);
    	while(c--)
    	{
    		scanf("%d%d",&n,&m);
    		printf(n%(m+1)?"first\n":"second\n");
    	}
    	return 0;
    }
    

    Pascal :

    var c,n,m,i:integer;
    begin
      read(c);
      for i:=1 to c do
      begin
        read(n); read(m);
        if n mod (m+1)=0 then writeln('second')
        else writeln('first');
      end;
    end.
    

    Java :

    import java.util.*;
    
    public class Main{
      final static Scanner jin=new Scanner(System.in);
      public static void main(String args[]){
        int C=jin.nextInt();
        while(C-->0){
          int n=jin.nextInt(),m=jin.nextInt();
          if(n%(m+1)!=0)
            System.out.println("first");
          else
            System.out.println("second");
        }
      }
    }
    
    • 1

    Information

    ID
    20015
    Time
    1000ms
    Memory
    32MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By