首页 > 其他分享 >题解:P10765 「CROI · R2」在相思树下 I

题解:P10765 「CROI · R2」在相思树下 I

时间:2024-07-14 18:26:58浏览次数:9  
标签:pre R2 int 题解 scanf CROI ans lld

在发布求救信号后,@我就在这里253发了题解。

#include<bits/stdc++.h>
using namespace std;
#define int long long
int t, ans;
void solve() {
	int n, k, x, ans;
	scanf("%lld%lld", &n, &k);
	ans = 1;
	int pre = 1, behind = n;
	for (int i = 0; i < k; i++) {
		scanf("%lld", &x);
		if (x == 1) {
			pre += ans;
		} else if (x == 2) {
			behind -= ans;
		}
		ans *= 2;
	}
	printf("%lld\n", pre);
}
signed main() {
	scanf("%lld", &t);
	while (t--) {
		solve();
	}
	return 0;
}

感谢大家的支持!
(我绝对不会告诉你我用了3个流量券才得到一个题解)

标签:pre,R2,int,题解,scanf,CROI,ans,lld
From: https://blog.csdn.net/yonghen210000/article/details/140420469

相关文章

  • 题解 P1007 独木桥
    link题意\(N\)个人在长度为\(L\)独木桥上走动,桥上的坐标为\(1,2,\cdots,L\),你不知道他们的方向。他们的速度都为\(1\)。当两个人相遇时,他们就分别转身,继续行走。(转身不花费时间)当某人来到\(0\)或\(L+1\)的位置,他就离开了独木桥。给定\(N\)、\(L\)和\(......
  • 2021杭电多校10 D.Pty hates prime numbers题解
    前言暑期第三次组队赛是选的21年杭电多校10,遗憾爆0,被对面队打爆,赛后狠狠补题。这道题的题解,以及网上搜到的其他题解看了好久没看懂,在问了队里大腿多次后,总算磨出来了,这里讲一下我的理解。题意多次询问,每次给定\(n\)和\(k\),如果一个数的质因数里包括前\(k\)个质数,则这个数......
  • NSIS 之 NsDialogs 常见问题解答
    如何启用/禁用控件使用标准NSIS EnableWindow 命令。NSDialogs允许您弹出通过 ${NSD_Create*} 创建的控件的 hwnd (句柄)。EnableWindow 将 hwnd 作为其参数之一。通过它,您可以轻松启用/禁用控件。  !include"nsDialogs.nsh"!include"winmessages.nsh"!incl......
  • 题解:AT_abc362_d [ABC362D] Shortest Path 3
    一句话题意:给定一个带点权的有权无向连通图,求点1到所有其它点的最短路径。首先,只有1一个起点,所以是单源最短路,又因为最大是\(2\times10^5\),所以是优先队列(堆)优化过后的Dijkstra。所以,我们只需要解决点权的问题就好了。一种显而易见的想法是把与这条边的边权加上起终点......
  • Android Viewpager2 remove fragmen不生效解决方案
    一、介绍在如今的开发过程只,内容变化已多单一的fragment,变成连续的,特别是以短视频或者直播为主的场景很多。从早起的Viewpage只能横向滑动,到如今的viewpage2可以支持横向或者竖向滑动。由于viewpage2的adapter在设计时支持缓存,导致想立马生效出现问题,不符合国内的业务场景。......
  • 题解:CodeForces 346A Alice and Bob[博弈/数论]
    CodeForces346AA.AliceandBobtimelimitpertest2secondsmemorylimitpertest256megabytesinputstandardinputoutputstandardoutputItissoboringinthesummerholiday,isn'tit?SoAliceandBobhaveinventedanewgametoplay.Therulesa......
  • 题解:CodeForces 843A Sorting by Subsequences[模拟/排序]
    CodeForces843AA.SortingbySubsequencestimelimitpertest:1secondmemorylimitpertest:256megabytesinputstandardinputoutputstandardoutputYouaregivenasequence\(a_1, a_2, ..., a_n\)consistingofdifferentintegers.Itisrequiredtos......
  • 题解:CodeForces 618C Constellation[贪心/模拟]
    CodeForces618CC.Constellationtimelimitpertest:2secondsmemorylimitpertest:256megabytesinputstandardinputoutputstandardoutputCatNokuhasobtainedamapofthenightsky.Onthismap,hefoundaconstellationwithnstarsnumberedfrom......
  • 题解:CodeForces 835 D Palindromic characteristics[区间dp/马拉车Manacher]
    CodeForces835DD.Palindromiccharacteristicstimelimitpertest:3secondsmemorylimitpertest:256megabytes*inputstandardinputoutputstandardoutputPalindromiccharacteristicsofstring\(s\)withlength\(|s|\)isasequenceof\(|s|\)in......
  • 题解:CodeForces 1019 A Elections[贪心/三分]
    CodeForces1019AA.Electionstimelimitpertest:2secondsmemorylimitpertest:256megabytesinput:standardinputoutput:standardoutputAsyouknow,majorityofstudentsandteachersofSummerInformaticsSchoolliveinBerlandforthemostparto......