Problem Description
Zero Escape, is a visual novel adventure video game directed by Kotaro Uchikoshi (you may hear about ever17?) and developed by Chunsoft.

Stilwell is enjoying the first chapter of this series, and in this chapter digital root is an important factor. 

This is the definition of digital root on Wikipedia:
The digital root of a non-negative integer is the single digit value obtained by an iterative process of summing digits, on each iteration using the result from the previous iteration to compute a digit sum. The process continues until a single-digit number is reached.
For example, the digital root of  65536 is  7, because  6+5+5+3+6=25 and  2+5=7.

In the game, every player has a special identifier. Maybe two players have the same identifier, but they are different players. If a group of players want to get into a door numbered  X(1X9), the digital root of their identifier sum must be  X.
For example, players  {1,2,6} can get into the door  9, but players  {2,3,3} can't.

There is two doors, numbered  A and  B. Maybe  A=B, but they are two different door.
And there is  n players, everyone must get into one of these two doors. Some players will get into the door  A, and others will get into the door  B.
For example: 
players are  {1,2,6}A=9B=1
There is only one way to distribute the players: all players get into the door  9. Because there is no player to get into the door  1, the digital root limit of this door will be ignored.

Given the identifier of every player, please calculate how many kinds of methods are there,  mod 258280327.
 

Input
The first line of the input contains a single number  T, the number of test cases.
For each test case, the first line contains three integers  nA and  B.
Next line contains  n integers  idi, describing the identifier of every player.
T100n105n1061A,B,idi9
 

Output
For each test case, output a single integer in a single line, the number of ways that these  n players can get into these two doors.
 

Sample Input
4 3 9 1 1 2 6 3 9 1 2 3 3 5 2 3 1 1 1 1 1 9 9 9 1 2 3 4 5 6 7 8 9
 

Sample Output
1 0 10 60
 


网上找到了好多题解 特别不懂%9这是怎么来的 这个代码还算避开了这个问题 哈哈

与原数组相同那里 9 是怎么来的呢  举个栗子~ 之前和是9 当前位是8 相加得17=>再取根是8 其他同理

#include<cstdio>
#include<cstring>
#include <iostream>
#define mod 258280327
using namespace std;
int dp[100005][10];
int arr[100005];
//按给定规则转化为个位数
int modify(int x)
{
    int res=0;
    while(x)
    {
        res+=(x%10);
        x/=10;
    }
    if(res>9)
        return modify(res);
    else
        return res;
}
int main()
{
    //freopen("cin.txt","r",stdin);
    int t,n,a,b,tmp,ans;
    int sum,xx;
    scanf("%d",&t);
    while(t--)
    {
        sum=0;
		//初始化
        memset(dp,0,sizeof(dp));
        scanf("%d%d%d",&n,&a,&b);
		//读入
        for(int i=1;i<=n;i++)
            scanf("%d",&arr[i]);
        for(int i=1;i<=n;i++)
        {
            sum+=arr[i];
        }
        //sum=modify(sum);
        sum=(sum-1)%9+1;<span style="font-family: Arial, Helvetica, sans-serif;">//也可调用modify函数</span>

        xx=a+b;
        xx=(xx-1)%9+1;//也可调用modify函数
		//看是否相等
        if(sum==xx)
        {
          dp[1][arr[1]]=1;
          for(int i=2;i<=n;i++)
          {
			  dp[i][0]=1;
              for(int j=1;j<=9;j++)
              {
                  tmp=j-arr[i];
                  if(tmp<0)
				  {
					tmp+=9;
					//当前位取,那么就由之前的对应推过来,当前位不取,那么就是之前的相同的
				    dp[i][j]=(dp[i-1][tmp]+dp[i-1][j])%mod;
				  }
				  //如果当前位刚好和原数组相同,可以是如下三种情况(理解重点)
				  //1.当前位不取,那么方案数为之前一位的对应值
				  //2.也可以是前面一位为9,然后取当前位的情况
				  //3.也可以是前面都不取,只取当前位,故为1
				  else if(tmp==0)
					  dp[i][j]=(dp[i-1][9]+dp[i-1][j]+1)%mod;
				  else
					dp[i][j]=(dp[i-1][j]+dp[i-1][tmp])%mod;
              }
          }
		  //有可能a中都不取,只取b,b和sum相等(很容易遗漏)
		  if(b==sum)
		    printf("%d\n",(dp[n][a]+1)%mod);
		  else
			 printf("%d\n",(dp[n][a]));
       }
		//不相等,只可能单独在一扇门中
       else
       {
           ans=0;
           if(sum==a)
              ans++;
           if(sum==b)
               ans++;
           printf("%d\n",ans);
       }
    }
    return 0;
}