“今日头条杯”首届湖北省大学程序设计竞赛(网络同步赛 )--E. DoveCCL and Resistance
题目描述:链接点此
这套题的github地址(里面包含了数据,题解,现场排名):点此
链接:https://www.nowcoder.com/acm/contest/104/D
来源:牛客网
题目描述
Do you remember Kanna-chan we met last year? She is so cute, and this year, she entered middle school, with Cirno. As we know, Cirno is bad at math, so she had trouble when studying physics.
Today, Kanna-chan's teacher is preparing for mid-term exam, one of the problem looks like follows:
Please calculate the equivalent resistance of the circuit below.
As Kanna-chan's teacher is too lazy, so he asked you for help, he will give you the answer of the problem, and your task is to generate a valid circuit satisfies that it's equivalent resistance equals to the answer.
输入描述:
Input contains one line with two integers, p and q, means the answer of the problem should be p/q, where ,
.
输出描述:
Output a circuit satisfy teacher's request. The first line of your input should be two integers, n and m, n is the number of nodes and m is the number of resistance you used. Where
Then m lines follows, each line contains three integers, ,which means that there is a wi-Ohm resistance connected between ui and vi,
, multiple resistances can be used between two nodes.
Then output two integers s, t, , means that the equivalent resistance between node s and node t equals to p/q.
输入例子:
22 9
输出例子:
3 4
1 2 2
2 3 1
2 3 1
2 3 4
1 3
-->
输入
22 9
输出
3 4
1 2 2
2 3 1
2 3 1
2 3 4
1 3
说明
/*
author:gsw
data:2018.04.30
link:https://www.nowcoder.com/acm/contest/104/B
accout:1697782237@qq.com(tonygsw)
*/
#define ll long long
#define IO ios::sync_with_stdio(false); #include<math.h>
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int m,n;
void dg(int x,int y,int k,int num)
{
if(y==)return;
n=max(num,n);
int a=x/y;
m++;
x=x-a*y;
if(x==){
m++;return;
}
int b=y/x;
m+=b;
int y1=y-b*x;
int x1=x;
dg(x1,y1,num,num+);
}
void print(int x,int y,int k,int num)
{
if(y==)return;
int a=x/y;
printf("%d %d %d\n",k,num,a);
x=x-a*y;
if(x==)
{
printf("%d %d %d\n",num,,);
return;
}
int b=y/x;
for(int i=;i<b;i++)
printf("%d %d %d\n",num,,);
int y1=y-b*x;
int x1=x;
print(x1,y1,num,num+);
}
int p,q; int main()
{
scanf("%d%d",&p,&q);
n=m=;
dg(p,q,,);
printf("%d %d\n",n,m);
print(p,q,,);
printf("1 2");
}
“今日头条杯”首届湖北省大学程序设计竞赛(网络同步赛 )--E. DoveCCL and Resistance的更多相关文章
- “今日头条杯”首届湖北省大学程序设计竞赛--F. Flower Road
题目链接:点这 github链接:(包含数据和代码,题解):点这 链接:https://www.nowcoder.com/acm/contest/104/E来源:牛客网 题目描述 (受限于评测机,此题 ...
- A. Srdce and Triangle--“今日头条杯”首届湖北省大学程序设计竞赛(网络同步赛)
如下图这是“今日头条杯”首届湖北省大学程序设计竞赛的第一题,作为赛后补题 题目描述:链接点此 这套题的github地址(里面包含了数据,题解,现场排名):点此 Let be a regualr tr ...
- I. Five Day Couple--“今日头条杯”首届湖北省大学程序设计竞赛(网络同步赛)
题目描述:链接点此 这套题的github地址(里面包含了数据,题解,现场排名):点此 链接:https://www.nowcoder.com/acm/contest/104/H来源:牛客网 题目描述 ...
- D. Who killed Cock Robin--“今日头条杯”首届湖北省大学程序设计竞赛(网络同步赛)
题目描述:链接点此 这套题的github地址(里面包含了数据,题解,现场排名):点此 题目描述 由于系统限制,C题无法在此评测,此题为现场赛的D题 Who killed Cock Robin? I, ...
- H. GSS and Simple Math Problem--“今日头条杯”首届湖北省大学程序设计竞赛(网络同步赛)
题目描述:链接点此 这套题的github地址(里面包含了数据,题解,现场排名):点此 题目描述 Given n positive integers , your task is to calculat ...
- “东信杯”广西大学第一届程序设计竞赛(同步赛)H
链接:https://ac.nowcoder.com/acm/contest/283/H来源:牛客网 题目描述 由于临近广西大学建校90周年校庆,西大开始了喜闻乐见的校园修缮工程! 然后问题出现了,西 ...
- 陕西师范大学第七届程序设计竞赛网络同步赛 I 排队排队排队【数组任一位可以移动到队头,最少移动几次增序/数组指针操作】
链接:https://www.nowcoder.com/acm/contest/121/I来源:牛客网 题目描述 ACM竞赛队内要开运动会啦!!!! 竞赛队内的一群阳光乐观积极的队员们迅速的在操场上站 ...
- 西安电子科技大学第16届程序设计竞赛网络同步赛 G-小国的复仇
sb找规律. 分解因数. #include<bits/stdc++.h> #define LL long long #define fi first #define se second # ...
- 陕西师范大学第七届程序设计竞赛网络同步赛 J 黑猫的小老弟【数论/法拉数列/欧拉函数】
链接:https://www.nowcoder.com/acm/contest/121/J来源:牛客网 题目描述 大家知道,黑猫有很多的迷弟迷妹,当然也有相亲相爱的基友,这其中就有一些二五仔是黑猫的小 ...
随机推荐
- Java中如何修改Jar中的内容
一.摘要 好长时间没写blog了,之前换了一家公司.表示工作更有战斗力了,可惜就是没时间写文章了.在这段时间其实是遇到很多问题的,只是都是记录下来,并没有花时间去研究解决.但是这周遇到这个问题没办法让 ...
- Service系统服务(三):查看进程信息、进程调度及终止、系统日志分析、使用systemctl工具
一.查看进程信息 目标: 本例要求掌握查看进程信息的操作,使用必要的命令工具完成下列任务: 找出进程 gdm 的 PID 编号值 列出由进程 gdm 开始的子进程树结构信息 找出进程 sshd 的父进 ...
- Monkeyrunner学习
可以写一个pyhon工程,安装在android进行测试,还可以截屏操作.Monkeyrunner为framework层开发.MonkeyRunner本身是Java做的,为了和Python连接,做了一个 ...
- leetcode上的一些动态规划
70-爬楼梯 思路:该问题可以理解为经典的“斐波那契数列”问题,但这里需要用动规实现,递归会超时 class Solution { public: int climbStairs(int n) { v ...
- JS-监听整个页面上的DOM树变化
# [在线预览](https://jsfiddle.net/1010543618/fyf913t0/) ## 方法 - 使用<Web API 接口>的<MutationObserve ...
- iiview Select 选择框打勾选中的内容label和展示的不一致
Select选择框里加入了OptionGroup.option ; 以及input输入框支持模糊搜索: 不一致的原因:缺少 :label-in-value="true";官方文档 ...
- MySQL高级学习笔记(五):查询截取分析
文章目录 慢查询日志 是什么 怎么玩 说明 查看是否开启及如何开启 默认 开启 那么开启了慢查询日志后,什么样的SQL才会记录到慢查询日志里面呢? Case 配置版 日志分析工具mysqldumpsl ...
- upc组队赛3 Congestion Charging Zon【模拟】
Congestion Charging Zon 题目描述 Tehran municipality has set up a new charging method for the Congestion ...
- mysql三种连接方式
sql四种连接方式demo: 表a 表b a.id与b.parent_id有关系 1.内连接:SELECT a.*,b.* from a INNER JOIN b ON a.id=b.parent_i ...
- apache2.2.25+tomcat7.0.47集群方案
因为公司项目在线人数的增加,随着现在硬件成本越来越低,大多数的生产环境内存大多都已经达到 16G,尤其最新的阿里云,客户的机器都是配置超高的java主机,但是Java的运行环境,内存使用有限 ,这样就 ...