焦作网络赛

J .

Jessie and Justin want to participate in e-sports. E-sports contain many games, but they don‘t know which one to choose, so they use a way to make decisions.

They have several boxes of candies, and there are ii candies in the i^{th}ith box, each candy is wrapped in a piece of candy paper. Jessie opens the candy boxes in turn from the first box. Every time a box is opened, Jessie will take out all the candies inside, finish it, and hand all the candy papers to Justin.

When Jessie takes out the candies in the N^{th}Nth box and hasn‘t eaten yet, if the amount of candies in Jessie‘s hand and the amount of candy papers in Justin‘s hand are both perfect square numbers, they will choose Arena of Valor. If only the amount of candies in Jessie‘s hand is a perfect square number, they will choose Hearth Stone. If only the amount of candy papers in Justin‘s hand is a perfect square number, they will choose Clash Royale. Otherwise they will choose League of Legends.

Now tell you the value of NN, please judge which game they will choose.

Input

The first line contains an integer T(1 \le T \le 800)T(1≤T≤800) , which is the number of test cases.

Each test case contains one line with a single integer: N(1 \le N \le 10^{200})N(1≤N≤10200) .

Output

For each test case, output one line containing the answer.

样例输入复制

4
1
2
3
4

样例输出复制

Arena of Valor
Clash Royale
League of Legends
Hearth Stone

题意 : 问你 n 是否是一个可开根数, 1-n-1求和是否是一个可开根数,判断输出即可

思路分析 : 套的JAVA牛顿迭代的板子

代码示例:

import java.math.BigInteger;
import java.math.*;
import java.math.BigInteger;
import java.util.Scanner;

import java.util.*;
public class Main
{
    public static BigInteger bigSqrt(String s){
         Scanner cin=new Scanner(System.in);
          BigInteger remain=BigInteger.ZERO;
          BigInteger odd=BigInteger.ZERO;
          BigInteger ans=BigInteger.ZERO;
          int group=0,k=0;
          if(s.length()%2==1)
          {
                  group=s.charAt(0)-‘0‘;
                  k=-1;
          }
          else
          {
                  group=(s.charAt(0)-‘0‘)*10+s.charAt(1)-‘0‘;
                  k=0;
          }
          for(int j=0;j<(s.length()+1)/2;j++)
          {
                  if(j!=0)
                  group=(s.charAt(j*2+k)-‘0‘)*10+s.charAt(j*2+k+1)-‘0‘;
                  odd=BigInteger.valueOf(20).multiply(ans).add(BigInteger.ONE);
                  remain=BigInteger.valueOf(100).multiply(remain).add(BigInteger.valueOf(group));
                  int count=0;
                  while(remain.compareTo(odd)>=0)
                  {
                         count++;
                         remain=remain.subtract(odd);
                         odd=odd.add(BigInteger.valueOf(2));
                  }
                  ans=ans.multiply(BigInteger.TEN).add(BigInteger.valueOf(count));
          }
//          System.out.println(ans);

//        cin.close();
        return ans;
    }
       public static void main(String[] args)
       {
    	   Scanner cin = new Scanner(System.in);
           int t;
   		   t = cin.nextInt();
   		   String s;
   		   BigInteger n;

   		   for(int i = 1; i <= t; i++) {
   			   n = cin.nextBigInteger() ;
   			   s = n.toString();
   			   BigInteger x = bigSqrt(s);
   			   BigInteger c1 = x.pow(2);
   			   int flag1 =  0;
   			   if (n.compareTo(c1) == 0) flag1 = 1;

   			   BigInteger m = n.subtract(BigInteger.ONE);
   			   BigInteger sum = n.multiply(m);
   			   BigInteger m2 = BigInteger.valueOf(2);
   			   sum = sum.divide(m2);
   			   s = sum.toString();
   			   x = bigSqrt(s) ;
   			   BigInteger c2 = x.pow(2);
   			   int flag2 =  0;
   			   if (sum.compareTo(c2) == 0) flag2 = 1;

   			if ((flag1 == 1) && (flag2 == 1)) System.out.println("Arena of Valor");
	        else if ((flag1 == 1) && (flag2 == 0)) System.out.println("Hearth Stone");
	        else if ((flag1 == 0) && (flag2 == 1)) System.out.println("Clash Royale");
	        else System.out.println("League of Legends");

   		   }

              cin.close();
      }
}

L .

God Water likes to eat meat, fish and chocolate very much, but unfortunately, the doctor tells him that some sequence of eating will make them poisonous.

Every hour, God Water will eat one kind of food among meat, fish and chocolate. If there are 333 continuous hours when he eats only one kind of food, he will be unhappy. Besides, if there are 333 continuous hours when he eats all kinds of those, with chocolate at the middle hour, it will be dangerous. Moreover, if there are 333 continuous hours when he eats meat or fish at the middle hour, with chocolate at other two hours, it will also be dangerous.

Now, you are the doctor. Can you find out how many different kinds of diet that can make God Water happy and safe during NNN hours? Two kinds of diet are considered the same if they share the same kind of food at the same hour. The answer may be very large, so you only need to give out the answer module 100000000710000000071000000007.

Input

The fist line puts an integer TTT that shows the number of test cases. (T≤1000T \le 1000T≤1000)

Each of the next TTT lines contains an integer NNN that shows the number of hours. (1≤N≤10101 \le N \le 10^{10}1≤N≤1010)

Output

For each test case, output a single line containing the answer.

样例输入

3
3
4
15

样例输出

20
46
435170题意 : 有 3 种饮食,告诉你一些连续3天饮食搭配不健康的情况,问N天后饮食健康的方案有多少种?思路分析 : 首先若只有两天的话,则有 9种情况,均符合要求,第三天再添加的时候纸上推一下,发现其实就是个 9*9的矩阵,一个矩阵快速幂即可代码示例:
#define ll long long
const ll maxn = 1e6+5;
const ll mod = 1e9+7;
const double eps = 1e-9;
const double pi = acos(-1.0);
const ll inf = 0x3f3f3f3f;

char s[1000];
struct mat
{
    ll a[15][15];
};
const ll modulu[15][15] = {
    {0, 0, 0, 1, 0, 0, 1, 0, 0},
    {1, 0, 0, 1, 0, 0, 1, 0, 0},
    {1, 0, 0, 1, 0, 0, 0, 0, 0},
    {0, 1, 0, 0, 1, 0, 0, 1, 0},
    {0, 1, 0, 0, 0, 0, 0, 1, 0},
    {0, 1, 0, 0, 1, 0, 0, 0, 0},
    {0, 0, 1, 0, 0, 0, 0, 0, 1},
    {0, 0, 0, 0, 0, 1, 0, 0, 1},
    {0, 0, 1, 0, 0, 1, 0, 0, 0}
};
ll n;
mat mul(mat a, mat b){
    mat r;
    memset(r.a, 0, sizeof(r.a));

    for(ll i = 0; i < 9; i++){
        for(ll j = 0; j < 9; j++){
            for(ll k = 0; k < 9; k++){
                r.a[i][j] += (a.a[i][k]*b.a[k][j])%mod;
                r.a[i][j] %= mod;
            }
        }
    }
    return r;
}

mat qpow(mat a, ll x){
    mat b;
    memset(b.a, 0, sizeof(b.a));
    for(ll i = 0; i < 9; i++) b.a[i][i] = 1;

    while(x){
        if (x&1) b = mul(b, a);
        a = mul(a, a);
        x >>= 1;
    }
    return b;
}

int main() {
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ll t;

    cin >> t;
    while(t--){
        cin >> n;
        mat a;
        memcpy(a.a, modulu, sizeof(modulu));
        if (n == 1) {printf("3\n"); continue;}
        else if (n == 2) {printf("9\n"); continue;}

        a = qpow(a, n-2);
        ll sum = 0;
        for(ll i = 0; i < 9; i++){
            for(ll j = 0; j < 9; j++){
                sum = (sum+a.a[i][j])%mod;
            }
        }
        printf("%lld\n", sum);
    }
    return 0;
}

原文地址:https://www.cnblogs.com/ccut-ry/p/9652595.html

时间: 2024-11-10 19:25:53

焦作网络赛的相关文章

焦作网络赛L-Poor God Water【矩阵快速幂】

God Water likes to eat meat, fish and chocolate very much, but unfortunately, the doctor tells him that some sequence of eating will make them poisonous. Every hour, God Water will eat one kind of food among meat, fish and chocolate. If there are 33 

2018焦作网络赛B

dp维护一下最大值与最小值,注意边界情况的判定. #include <iostream> #include <cstring> using namespace std; const long long inf = (long long)1e18+(long long)9; long long dp[7][1005]; long long dpx[7][1005]; int f[1005]; char s[15]; int main() { int T; // int l; int

2018焦作网络赛E

区间更新加法与乘法,x取反是2^64-x-1,由于取模所以取反变成-x-1,就区间+1再*-1就可以了,最后区间询问求和. 待补 原文地址:https://www.cnblogs.com/LMissher/p/9655105.html

2018焦作网络赛 - Poor God Water 一道水题的教训

本题算是签到题,但由于赛中花费了过多的时间去滴吧格,造成了不必要的浪费以及智商掉线,所以有必要记录一下 题意:方格从1到n,每一格mjl可以选择吃鱼/巧克力/鸡腿,求走到n格时满足 1.每三格不可重复同一种食物 2.每三格均不同食物时中间格子不可吃巧克力 3.每三格前后两格不可同时吃巧克力 以上三个条件的方案数,n<1e10 太长不看版:打表+快速幂AC 长篇吐槽版 很显然的,设\(dp[n][i][j][k]\),走到第\(n\)格时第\(n-2\)格的食物是\(i\),第\(n-1\)的食物

2018焦作网络赛J

不知道题意,队友用java大数+二分过了? import java.util.Arrays; import java.util.Scanner; import java.io.*; import java.math.*; public class Main { static boolean check(BigInteger num,BigInteger n) { boolean flag = true; BigInteger a = new BigInteger("0"); BigIn

2018焦作网络赛-E- Jiu Yuan Wants to Eat

题目描述 You ye Jiu yuan is the daughter of the Great GOD Emancipator.  And when she becomes an adult, she will be queen of Tusikur, so she wanted to travel the world while she was still young. In a country, she found a small pub called Whitehouse. Just

2018焦作网络赛G-Give Candies

G: Give Candies 时间限制: 1 Sec  内存限制: 128 MB 题目描述 There are N children in kindergarten. Miss Li bought them N candies.To make the process more interesting, Miss Li comes up with the rule: All the children line up according to their student number (1…N),

2018焦作网络赛B-Mathematical Curse

B: Mathematical Curse 时间限制: 1 Sec  内存限制: 128 MB 题目描述 A prince of the Science Continent was imprisoned in a castle because of his contempt for mathematics when he was young, and was entangled in some mathematical curses. He studied hard until he reach

2018焦作网络赛 E Jiu Yuan Wants to Eat(线段树+树链剖分)

题意 对一个有1e5个点,点权初值为0的树上进行4种操作: 1.结点u到结点v上的所有点权乘x. 2.结点u到结点v上所有的点权加x. 3.结点u到结点v上所有的点权取非. 4.结点u到结点v路径上点权的和. 答案模\(2^{64}\) 思路 对操作1.2树链剖分加线段树维护即可,对操作3,取非操作为:一个二进制位上都为1 的数减去当前值,即:\(2^{64}-1-x\) , 由于答案模\(2^{64}\),通过点权用unsigned long long,只需维护\(-(x+1)\) 操作即可.