首页 > 其他分享 >D. Yarik and Musical Notes

D. Yarik and Musical Notes

时间:2024-03-22 22:12:18浏览次数:26  
标签:idx int Yarik Notes id xx mplst include Musical

一道有趣的思维题
经过推理,最后的答案只有两种构成:
1.1的数目*2的数目
2.所有相同的数n,进行C(2,n)然后相加
像这样,然后把比值设成k,可以知道只能枚举如上两类

https://codeforces.com/problemset/problem/1899/D

#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<sstream>
#include<string>
#include<string.h>
#include<iomanip>
#include<stdlib.h>
#include<map>
#include<queue>
#include<limits.h>
#include<climits>
#include<fstream>
#include<stack>
typedef long long ll;
using namespace std;




queue<ll>id;
int main()
{
	int t; cin >> t;
	for (int ii = 0; ii < t; ii++)
	{
		map<ll, ll>mplst;
		ll ans = 0;
		int n; cin >> n; int xx;
		if (n == 1) { cout << 0 << endl; cin >> xx; }
		else
		{
			for (int i = 0; i < n; i++)
			{
				cin >> xx;
				if (!mplst[xx])id.push(xx);
				mplst[xx]++;

			}
			ans += mplst[1] * mplst[2];//第一类
			while (!id.empty())
			{
				ll idx = id.front();
				id.pop();
				if (mplst[idx] > 1)ans += mplst[idx] * (mplst[idx] - 1) / 2;//第二类
			}
			cout << ans << endl;
		}
	}
	return 0;
}

标签:idx,int,Yarik,Notes,id,xx,mplst,include,Musical
From: https://www.cnblogs.com/zzzsacmblog/p/18090497

相关文章

  • 【Coursera GenAI with LLM】 Week 3 Reinforcement Learning from Human Feedback Cl
    Helpful?Honest?Harmless?MakesureAIresponseinthose3ways.Ifnot,weneedRLHFisreducethetoxicityoftheLLM.Reinforcementlearning:isatypeofmachinelearninginwhichanagentlearnstomakedecisionsrelatedtoaspecificgoalbytakin......
  • 【Coursera GenAI with LLM】 Week 2 PEFT Class Notes
    WithPEFT,weonlytrainonsmallportionofparameters!What'susingmemorywhiletrainingmodel?TrainableweightsOptimizerstatesGradientsForwardActivationsTemporarymemoryPEFTTrade-offsParameterEfficiencyMemoryEfficiencyModelPerfo......
  • 【Coursera GenAI with LLM】 Week 2 Fine-tuning LLMs with instruction Class Notes
    GenAIProjectLifecycle:Afterpickingpre-trainedmodels,wecanfine-tune!In-contextlearning(ICL):zero/one/fewshotinference.Includingafewmodelsinthepromptformodeltolearnandgenerateabettercomplement(akaoutput).Itsdrawbacks......
  • MLE / AIE Notes in Python
    ......
  • geotools Release Notes
    参考:Releases·geotools/geotools·GitHub ......
  • laravel_release notes
    参考网址:https://laravel.com/docs/10.x/releasesReleaseNotes发行说明VersioningScheme版本控制方案Laravelanditsotherfirst-partypackagesfollowSemanticVersioning.Majorframeworkreleasesarereleasedeveryyear(~Q1),whileminorandpatchrelea......
  • 开源免费的专注于建立大型个人知识库推荐-Trilium Notes
        TriliumNotes是一个分层的笔记应用程序,专注于建立大型个人知识库。支持相当丰富的markdown,包括mermaid和latex,而且即时渲染,和typora一样。支持代码类型的笔记,有高亮。 Trilium与其说是笔记软件,不如说是个人wiki。个人知识数据库、收藏夹、代码块、手账、思......
  • (亲测)使用Docker部署flatnotes笔记工具
    展示一、flatnotes介绍1.1flatnotes简介flatnotes是一个自托管的、无数据库的笔记Web应用程序,它利用文件夹存储Markdown文件。1.2flatnotes特点移动响应式web界面。原始/所见即所得标记编辑器模式。高级搜索功能。注意“标记”功能。浅色/深色主题。多个身份验证选项(无、只......
  • Kotlin Notes - 6
    Toaccessthisfromanouterscope(aclass,extensionfunction,orlabeledfunctionliteralwithreceiver)youwritethis@label,where@labelisalabelonthescopethisismeanttobefrom:classA{//implicitlabel@AinnerclassB{//implicit......
  • Kotlin Notes - 5
    InKotlin,thetypesystemdistinguishesbetweenreferencesthatcanholdnull(nullablereferences)andthosethatcannot(non-nullablereferences).Forexample,aregularvariableoftypeStringcannotholdnull:vara:String="abc"//Regul......