Deep_Dev

https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=3&contestProbId=AWksRkI6AR0DFAVE&categoryId=AWksRkI6AR0DFAVE&categoryType=CODE&problemTitle=&orderBy=INQUERY_COUNT&selectCodeLang=ALL&select-1=3&pageSize=10&pageIndex=7 

 

SW Expert Academy

SW ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์—ญ๋Ÿ‰ ๊ฐ•ํ™”์— ๋„์›€์ด ๋˜๋Š” ๋‹ค์–‘ํ•œ ํ•™์Šต ์ปจํ…์ธ ๋ฅผ ํ™•์ธํ•˜์„ธ์š”!

swexpertacademy.com

 


์ž…๋ ฅ๋ฐ›์€ ์ˆซ์ž ๊ทธ๋Œ€๋กœ ์ž๋ฆฟ์ˆ˜๋ฅผ ๋”ํ•ด์„œ -1ํ•œ ์ˆซ์ž๋กœ ๋‚˜๋ˆ ์ฃผ๋ฉด ๋œ๋‹ค.

 

( int ์ž๋ฆฟ์ˆ˜ ๋ง์…ˆ์€ ๋ฒ”์œ„๊ฐ€ ๋„ˆ๋ฌด ์ปค์„œ ์•ˆ๋จ )

 

import java.util.*;

public class Solution {
    public static void main(String[] args) {
        Scanner kb = new Scanner(System.in);
        int T = kb.nextInt();
        for (int t = 1; t <= T; t++) {
            int n =kb.nextInt();
            String s=kb.next();
            long sum=0;
            for(int i=0; i<s.length(); i++){
                sum+=s.charAt(i)-'0';
            }
            long answer=sum%(n-1);
            System.out.println("#"+t+" "+answer);
        }
    }
}