Click to open the question link
This question cannot be viewed as violent. You can only find the rule and push the formula.
The question requires that the sum of the remaining numbers after each fetch is a multiple of 3. How many of the elements that constitute the remaining sum are multiples of 3, if there are count in the statistics, all the remaining count except this Count must not be divisible by 3, but the number and the sum of the three cannot be divisible by 3. Imagine, if I take one of them, then the sum of all the remaining numbers cannot be divided by 3, which means the elements cannot be obtained. Therefore, each operation can only be an element multiple of 3, if you know that an individual does not have an element that is a multiple of 3, you will lose !!!
# Include <iostream> # include <cstring> using namespace STD; int main (INT argc, char * argv []) {int t, n, I, j, sum, count, sum1, count1, TT = 0; char a [10005], ans; CIN> T; while (t --) {CIN> A; ans = 'T '; for (I = COUNT = sum = 0; I <strlen (a); I ++) {sum + = A [I]-'0 '; if (A [I]-'0') % 3 = 0) Count ++;} for (I = 0; I <strlen (a); I ++) {sum1 = sum-(A [I]-'0'); count1 = count; If (sum1% 3 = 0) {If (A [I]-'0') % 3 = 0) count1 --; If (count1% 2 = 0) {ans ='s '; break ;}}cout <"case" <++ TT <":" <ans <Endl;} return 0 ;}