패키지 테스트; import java.math.BigInteger; import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); 문자열 s = sc.nextLine(); int[] preSum = new int[s.length() + 1]; for (int i = 1; i <= s.length(); i++) { preSum[i] = preSum[i-1]+s.charAt(i-1)-'0'; } 정수 해상도 = 0; 정수 마지막 = 0; for (int i = 1; i <= s.length(); i++) { System.out.println(preSum[i]); for (int j = last; j < i; j++) { 마지막 = 나; if ((preSum[i] - preSum[j]) % 7 == 0) { 입술++; } } } System.out.println(res); } }
일련의 숫자를 가능한 한 7로 나눌 수 있는 숫자로 자릅니다. 예를 들어 일련의 숫자 12457은 124|5|7로 나눌 수 있습니다. 7로 나눌 수 있는 세그먼트가 두 개 있습니다. 절단 후 세그먼트 숫자의 합은 7로 나눌 수 있습니다.
추천
출처blog.csdn.net/w20001118/article/details/126805997
추천
행