SDNU

您所在的位置:网站首页 acmicpc2022 SDNU

SDNU

#SDNU| 来源: 网络整理| 查看: 265

SDNU_ACM_ICPC_2022_Weekly_Practice_1rd「个人赛」 A – A Recursive Function 题目描述:

定义一个函数f(x)

f(0) = 1 f(x) = x*f(x-1)

输入n,输出f(n)

思路:

诈骗题,其实就是输出n的阶乘,不过直接按照题意模拟递归也行

注意数据范围不会爆longlong,所以用int就行

//循环版 #include using namespace std; int n; int main(){ cin >> n; int ans = 1; for(int i = 1; i > k; ll mul = 1;//记录10的i-1次方 for(int i = 1; i = 5){//如果大于等5,则需要进位,即n加上10-x个mul n += (10-x)*mul; } else n -= x*mul;//小于等于4,则需要将第i位变成0,即n减去x个mul mul *= 10; } cout n; mapmp, num; for(int i = 1; i > tr[i]; ++mp[tr[i]];//去重 } int id = 0; for(auto [x, y] : mp){//用auto来遍历map ++id;//记录比他小的数字的数量 num[x] = (int)mp.size() - id;//容器大小-比他小的数字的数量就能计算出大于它的不同的数字的数量 } for(int i = 1; i > m >> x >> y; cin >> k; for(int i = 1; i > tr[i].x >> tr[i].y; } sort(tr + 1, tr + 1 + k, cmp1); ll h=0, l=0; maphang, lie; for(int i = 1; i op >> len; if(op == 'L'){ if(!hang.count(x)){ y = max(1ll, y-len); } else{ ll id = hang[x]; if(ar[id].front() > y){ y = max(1ll, y - len); } else{ ll pos = lower_bound(ar[id].begin(), ar[id].end(), y) - ar[id].begin()-1; y = max(ar[id][pos]+1, y-len); } } cout k >> x; cout x; if(x> m; cout y,我们想拿钥匙就得先开门,但是开不了门,所以就无法到达,输出-1 如果钥匙z>0,也就是在起点和门之间,那就从起点出发拿了钥匙开了门直接到终点,输出x就行 如果钥匙z x >> y >> z; if(x == 0){ cout x)cout


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3