NYOJ 158 省赛来了
省赛来了
- 描写叙述
-
一年一度的河南省程序设计大赛又要来了。
竞赛是要组队的,组队形式:三人为一队,设队长一名。队员两名。
如今问题就来了,给你m个人,要求每队n个人。求共同拥有几种不同的组队方式。
(题目保证m%n等于0,全部数据不超出int范围)
- 输入
- 多组測试数据,以EOF结束。
每组測试数据输入两个整数m,n。 - 输出
- 对每组測试数据输出不同组队方式的数量(考虑到输出的数可能会非常大,所以请输出对2013取余后的值)。并在输出结束之后输入一个换行符。
- 例子输入
-
4 2
- 例子输出
-
6
组合问题!
AC码:
#include<stdio.h>
int C(int m,int n)
{
int cm=1,cn=1,i;
for(i=2;i<=n;i++)
cn*=i;
for(i=m-n+1;i<=m;i++)
cm*=i;
return cm/cn;
}
int main()
{
int m,n;
while(~scanf("%d%d",&m,&n))
{
int res=1;
while((m/n)>1)
{
res=res*C(m,n)%2013;
m-=n;
}
printf("%d\n",res);
}
return 0;
}
NYOJ 158 省赛来了的更多相关文章
- NYOJ 1272 表达式求值 第九届省赛 (字符串处理)
title: 表达式求值 第九届省赛 nyoj 1272 tags: [栈,数据结构] 题目链接 描述 假设表达式定义为: 1. 一个十进制的正整数 X 是一个表达式. 2. 如果 X 和 Y 是 表 ...
- [河南省ACM省赛-第三届] 房间安排 (nyoj 168)
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=168 分析:找到一天中需要最多的房间即可 #include<iostream> ...
- [河南省ACM省赛-第三届] AMAZING AUCTION (nyoj 251)
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=251 规则: 1.若某竞标价唯一,则胜出 2.若不存在唯一竞标价,则投标次数最少竞标价中标 ...
- [河南省ACM省赛-第三届] 网络的可靠性 (nyoj 170)
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=170 根据题意,需要找到度数为1的结点个数,如下图: #include<iostre ...
- [河南省ACM省赛-第三届] BUYING FEED (nyoj 248)
#include<iostream> #include<cstdio> #include<algorithm> #include<cstring> us ...
- [河南省ACM省赛-第三届] 素数 (nyoj 169)
#include <iostream> #include <cstdio> #include <queue> #include <cstring> #i ...
- [河南省ACM省赛-第三届] 聪明的kk (nyoj 171)
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=171 动态规划: d(i,j) = max{d(i-1, j), d(i, j-1)}+m ...
- [河南省ACM省赛-第四届] 序号互换 (nyoj 303)
相似与27进制的转换 #include<iostream> #include<cstdio> #include<cstring> #include<strin ...
- [河南省ACM省赛-第四届] 表达式求值(nyoj 305)
栈的模拟应用: #include<iostream> #include<cstdio> #include<cstring> #include<string&g ...
随机推荐
- luogu P2865 路障
https://www.luogu.org/problemnew/show/P2865 看到题解好多dijkstra,作为一名钟爱于spfa的蒟蒻看不下去了. 有些spfa要跑两边,代码量要曾长好多( ...
- 洛谷P1421 小玉买文具
这道题其实就是编程最基础的逻辑,没什么好讲的输入,输出就完了,非常简单! code: #include<cstdio> #include<iostream> using nam ...
- django1.11 启动错误:Generator expression must be parenthesized
错误信息: Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0 ...
- JavaScript中上传文件为图片如何读取+JS中如何使用clip()剪切指定区域(UI组件之图片剪裁器)
File读取和FileReader() //获取上传的文件/图片 function getFile(){ var files,len; var reader = new FileReader(); v ...
- 【HTML/XML 4】实例分析HTML和XML的不同
导读:上回书说到,XML和HTML有着各自的不同点,综合表现在:1,HTML只是Web显示数据的通用方法,而XML提供了直接处理Web数据的通用方法.2,HTML着重描述Web页面的显示格式,而XML ...
- Gym - 100548C The Problem Needs 3D Arrays (最大密度子图)
TK在大多数 Unix平台.Windows平台和Macintosh系统都是预装好的,TKinter 模块是 Tk GUI 套件的标准Python接口.可实现Python的GUI编程. Tkinter模 ...
- Codeforces603E - Pastoral Oddities
Portal Description 初始时有\(n(n\leq10^5)\)个孤立的点,依次向图中加入\(m(m\leq3\times10^5)\)条带权无向边.使得图中每个点的度数均为奇数的边集是 ...
- 【最小费用最大流】N. April Fools' Problem (medium)
http://codeforces.com/contest/802/problem/N [题解] 方法一: #include<bits/stdc++.h> using namespace ...
- 如何打开Oracle的dmp文件
在工作中经常使用到别人提供过来的dmp文件,由于不知道备份时所用的用户名,这样就不能恢复. 通过打开DMP文件可以查看到备份时使用的用户名. 1.如果dmp文件比较小,用文本编辑器打开就可以了. 2. ...
- solr请求处理器列表
List of Request Handlers Available The Javadocs contain a complete list of Request Handlers. Many of ...