Snippets Collections
import java.util.*;
import java.io.*;

class Solution {
    public static long sumUnderModulo(long a, long b){
        
        long M = 1000000007;
        // a+b mod M = (a mod M + b mod M)mod M
        return  (a % M + b % M)%M;
    }   
}

class GFG
{
    public static void main(String args[])throws IOException
    {
        BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
        
        //taking testcases
        int t = Integer.parseInt(read.readLine());
        
        while(t-- > 0) {
            String[] str = read.readLine().trim().split(" ");
            
            //taking input a and b
            Long a = Long.parseLong(str[0]);
            Long b = Long.parseLong(str[1]);
            
            //calling method sumUnderModulo()
            System.out.println(new Solution().sumUnderModulo(a,b));
        }
    }
}
star

Sat Feb 05 2022 12:20:21 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/addition-under-modulo/1/?track=DSASP-Mathematics&batchId=190

#java #additionundermodulo #mathematics #gfg #geeksforgeeks

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension