MGLT-ICPC训练一(The 2019 ICPC Asia Danang Regional Contest)

题目:Abstract Painting Kattis - abstractpainting

分析:

一图胜千言(妙不可言,美不胜收,这题妙,我吃了)
在这里插入图片描述

代码:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//typedef __int128 lll;
#define print(i) cout << "debug: " << i << endl
#define close() ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define mem(a, b) memset(a, b, sizeof(a))
const ll mod = 1e9 + 7;
const int maxn = 2e6;
const int inf = 0x3f3f3f3f;

ll qpow(ll a, ll n)
{
    ll res = 1;
    while (n)
    {
        if(n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main()
{
    int t; cin >> t;
    while (t--)
    {
        int r, c; cin >> r >> c;
        cout << qpow(3, r + c) * qpow(2, r * c) % mod << endl;
    }
}

题目:D - Dating time

分析:

一开始枚举的是秒数,然后再求夹角,这样就会导致判断两个指针是否在这一秒内重合变得非常麻烦。本题正确打开方式应该将整个表分成43200份,夹角差值的单位设为1份,然后枚举份数即可。(wtcl)

代码:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//typedef __int128 lll;
#define print(i) cout << "debug: " << i << endl
#define close() ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define mem(a, b) memset(a, b, sizeof(a))
const ll mod = 1e9 + 7;
const int maxn = 2e6;
const int inf = 0x3f3f3f3f;
const int tim = 43200;

int main()
{
    int t; cin >> t;
    while (t--)
    {
        int h1, m1, h2, m2, tar;
        scanf("%d:%d %d:%d %d", &h1, &m1, &h2, &m2, &tar);
        int start = (h1 * 3600 + m1 * 60) * 11, end = (h2 * 3600 + m2 * 60) * 11;
        int res = 0;
        for(int i = start; i <= end; i++)
        {
            if(tar == 0 && i % tim == 0) res++;
            if(tar == 90 && (i % tim == 10800 || i % tim == 32400)) res++;
            if(tar == 180 && i % tim == 21600) res++; 
        }
        cout << res << endl;

    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值