AtCoder Regular Contest 113训练赛(暴力,快速幂,贪心)

ARC 113

传送门

A. A×B×C

https://atcoder.jp/contests/arc113/tasks/arc113_a

题意

给定一个正整数K,求出正整数排列(A,B,C),使A×B×C ≤ K,的组合个数。

思路

暴力,枚举A、B,求C的个数。

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<map>
#include<set>
#include<cstring>
#include<vector>
#include<queue>
#include<functional>
#include<string>
#define INF 0x7fffffff
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ls p<<1
#define rs p<<1|1
using namespace std;
typedef long long ll;
int k;

int main(){
   
   
    IOS;
    cin >> k;
    ll res = 0;
    for(int c = 1;c <= k;c++){
   
   
        int ab = 0;
        ab = k / c;
        for(int a = 1;a <= ab;a++){
   
   
            res += ab / a;
        }
    }
    cout << res << endl;
    system("pause");
    return 0;
}

B.A ^ B ^C

https://atcoder.jp/contests/arc113/tasks/arc113_b

题意

给定三个数A,B,C,求出 a b c a^{b^c} abc的个位上的数。

思路

①由于我们只需求解个位上数,所以A的个位以上的数对结果无影响,所以我们对A取余。
②找规律,我们发现0-9中每个数的n次方的个位上的数是具有规律性的,结果如下:a^n规律图
③利用快速幂计算 b c b^c bc对a所在周期取余的结果
④在记录a的n次幂的个位的数组中输出结果。

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<map>
#include<set>
#include<cstring>
#include<vector>
#include<queue>
#include<functional>
#include<string>
#define INF 0x7fffffff
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ls p<<1
#define rs p<<1|1
using namespace std;
typedef long long ll;
int abc[10][5];

ll pm(ll b,ll c,ll mod){
   
   
    ll res = 1;
    while(c){
   
   
        if(c & 1){
   
   
            (res *= b)%= mo
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值