BestCoder Round #75 解题报告

1.King‘s Cake

#include<stdio.h>
#include<iostream>
using namespace std;
int ans;
void solve(int l,int w)
{
    if(weight == 0||weight == 0)
        return 0;
    int t,tl,tw;
    t = l/w;
    ans += t;
    tw = w;
    w = l%w;
    l = tw;
    solve(l,w);
}
int main(void)
{
    int length,weight,cas;
    cin >> cas;

    while(cas--)
    {
        int t;
        ans = 0;
        cin >> length >> weigth;
        t = length;
        if(length < weight){
            length = weight;
            weight = t;
        }
        solve(length,weigth);
        cout >> ans >> endl;
    }
    return 0;
}

2.King‘s Phone

#include <iostream>
#include<string.h>
#include<stdio.h>

using namespace std;
int M[10],a[3][3];
void Init()
{
    int i,j;
    for(i = 0;i < 3;i ++)
        for(j = 0;j < 3;j ++)
            a[i][j] = 0;
}
int  Judge(int len)
{
    int i,j;
    for(i = 2;i <= len;i ++)
        for(j = i+1;j <= len;j ++){
              if((M[i]-1)/3 == (M[i-1]-1)/3)
                {
                    if((M[i]-1)/3 == (M[j]-1)/3&&(  (M[i]-M[j])*(M[i-1]-M[j])  < 0))
                        return 0;
              }
              else
              {
                  if(  ((M[i]-1)/3-(M[j]-1)/3)*((M[i-1]-1)/3-(M[j]/3-1))  < 0)
                   return 0;
              }
        }
        return 1;
}
int main()
{
    int cas;
    char m[18];
    cin >> cas;
    getchar();
    while(cas --){
        cin.get(m,18);
        getchar();
        //cout << m << endl;
        Init();
        int len = strlen(m);
        //cout << "len=" << len << endl;
        //cout << len << endl;
        int j = 1;
        for(int i=0;i < len;i += 2){
            M[j ++] = m[i] - ‘0‘;
        }
        int ans = Judge(len/2+1);
        if(ans)
            cout << "valid" << endl;
        else
            cout <<"invalid" <<endl;
    }
}

3.King‘s Order

#include <iostream>
#define jdz(a) a < 0?-a:a
using namespace std;
long long dp[2001][27],sum[2001];
void init()
{
    int i;
    sum[0] = 26;
    sum[1] = 26;
    sum[2] = 676;
    sum[3] = 17576;
    for(i = 0;i <= 26;i ++){
        dp[0][i] = 25;
        dp[1][i] = 1;
        dp[2][i] = 26;
        dp[3][i] = 676;
    }
}
/*
long long sum(int n)
{
    long long s = 1;
    while(n --)
    {
        s = (s * 26)%1000000007;
    }
    return s;
}
*/
int main()
{
    int cas,n;
    long long ans;
    cin >>cas;
    while(cas --)
    {
        ans = 0;
        cin >> n;
        int i;
        init();
        for(int i = 4;i <= n;i ++){
                sum[i] = 0;
            for(int j = 1;j <= 26;j ++){
                dp[i][j] = jdz((26*dp[i-1][j]%1000000007 - sum[i-4]%1000000007+dp[i-4][j]%1000000007))%1000000007;
                sum[i] = (sum[i]%1000000007+ dp[i][j]%1000000007)%1000000007;
            }
        }
        for(i = 1;i <= 26;i ++)
            ans = (ans%1000000007 + dp[n][i]%1000000007)%1000000007;
        cout << ans << endl;
    }
    return 0;
}
时间: 2024-08-01 16:52:36

BestCoder Round #75 解题报告的相关文章

BestCoder Round #86 解题报告

A.Price List Sol 求和查询 Code #include<cstdio> #include<algorithm> #include<iostream> using namespace std; typedef long long LL; const int N = 100005; //LL v[N]; inline LL in(LL x=0,char ch=getchar()){ while(ch>'9'||ch<'0') ch=getchar

BestCoder Round #40 解题报告

这场是第一场没有米的BC... 大概也是想震一震那些一听说没米了就不打BC的人吧 这次的题目质量比以往高了许多 (然而我并没有打这一场BC 但是今天下午到现在做的过程中真的学到了不少知识呢 A题略水... 1 #include<cstdio> 2 #include<cstdlib> 3 #include<cstring> 4 #include<cmath> 5 int T,n; 6 int main(){ 7 scanf("%d",&am

BestCoder Round #20 解题报告 A.B.C.

A题:who is the best? 题目地址:HDU 5123 水题. 哈希,然后枚举找最大的,从小的开始找. 代码如下: #include <iostream> #include <cstdio> #include <string> #include <cstring> #include <stdlib.h> #include <math.h> #include <ctype.h> #include <queu

BestCoder Round #39 解题报告

现场只做出前三题w 不过不管怎样这既是第一次认真打BC 又是第一次体验用在线编译器调代码 订正最后一题花了今天一整个下午(呜呜 收获还是比较大的^_^ Delete wld有n个数(a1,a2,...,an),他希望进行k次删除一个数的操作,使得最后剩下的n−k个数中有最多的不同的数,保证1≤n≤100,0≤k<n,1≤ai≤n(对于任意1≤i≤n) 比较简单的贪心... 把出现一次以上的多于一次的部分都删除掉 如果k依然>0就要删去k种不同的数 Multiple wld有一个序列a[1..n

BestCoder Round #75 - King&#39;s Phone

Problem Description It is the king's birthday before the military parade . The ministers prepared a rectangle cake of size n×m(1≤n,m≤10000) . The king plans to cut the cake himself. But he has a strange habit of cutting cakes. Each time, he will cut

BestCoder Round #75 King&amp;#39;s Order dp:数位dp

King's Order Accepts: 381 Submissions: 1361 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Problem Description After the king's speech , everyone is encouraged. But the war is not over. The king needs to give orders

hacker cup 2015 Round 1 解题报告

A:求区间内素因子个数等于n的数有多少个 解题思路:筛法 解题代码: 1 // File Name: a.cpp 2 // Author: darkdream 3 // Created Time: 2015年01月18日 星期日 13时54分20秒 4 5 #include<vector> 6 #include<list> 7 #include<map> 8 #include<set> 9 #include<deque> 10 #include&

Tinkoff Challenge - Elimination Round 部分解题报告

A. 如果存在的话,一定是所有的数化为最初的最小值,如果做不到就不可以. 1 #include <iostream> 2 #include <string> 3 #include <algorithm> 4 #include <cstring> 5 #include <cstdio> 6 #include <cmath> 7 #include <queue> 8 #include <set> 9 #includ

浙江省队选拔 ZJOI2015 (Round 1) 解题报告

最近莫名其妙地喜欢上了用这种格式写各省省选的全套题解= = 今年浙江省选的出题人是算法竞赛界传说级人物陈立杰,看样子他的出题风格很有特点……ABC三题难度是严格递减的,感觉如果在做第一题的时候被卡住的话恐怕连想死的心都有了…… 那么我们先从最难的一题开始……= = BZOJ 3924 A.幻想乡战略游戏 给定一棵N个结点的有正的边权.初始点权为0的无根树,进行M次操作,每次将一个点u的权值增加e($0 \leq |e| \leq 1000$),保证任意时刻点权非负.你的任务是在每次操作后找到一个