hdu 5666 Segment(简单整点计数题+快速乘)(bestcoder#80 1001)

共聚焦显微镜的光源、工作原理与选型 共聚焦显微镜作为科研与工业领域中重要的微观成像工具,凭借光源的精准适配性、光学切片技术的三维成像能力,以及对不同工业场景的定制化适配潜力,为半导体检测、工业部件分析、智能制造升级提供了关键技术支撑。深入理解其光源特性、工作原理与选型逻辑,能帮助工程师与技术人员精准匹配设备与生产需求,既保障微观检测的精度与效率,又为产业优化、技术创新筑牢微观观测的基础。 阅读详情

Problem Description
     Silen August does not like to talk with others.She like to find some interesting problems.

     Today she finds an interesting problem.She finds a segment  x+y=q .The segment intersect the axis and produce a delta.She links some line between  (0,0)  and the node on the segment whose coordinate are integers.

     Please calculate how many nodes are in the delta and not on the segments,output answer mod P.
 

Input
     First line has a number,T,means testcase number.

     Then,each line has two integers q,P.

    q  is a prime number,and  2≤q≤1018,1≤P≤1018,1≤T≤10.
 

Output
     Output 1 number to each testcase,answer mod P.
 

Sample Input
  
1 2 107
 

Sample Output
  
0
 

Source
 

Recommend
wange2014   |   We have carefully selected several similar problems for you:   5674  5673  5672  5671  5670 



Problem Description
     Silen August does not like to talk with others.She like to find some interesting problems.

     Today she finds an interesting problem.She finds a segment  x+y=q .The segment intersect the axis and produce a delta.She links some line between  (0,0)  and the node on the segment whose coordinate are integers.

     Please calculate how many nodes are in the delta and not on the segments,output answer mod P.
 

Input
     First line has a number,T,means testcase number.

     Then,each line has two integers q,P.

    q  is a prime number,and  2≤q≤1018,1≤P≤1018,1≤T≤10.
 

Output
     Output 1 number to each testcase,answer mod P.
 

Sample Input
  
1 2 107
 

Sample Output
  
0
 

Source
 

Recommend
wange2014   |   We have carefully selected several similar problems for you:   5674  5673  5672  5671  5670 

题目大意:

       给定一条斜率为-1截距为q的直线,求解他在第一象限围住的整点(不含边界)有多少个。

解题思路:

      规律是很明显的,最下面一行是q-2个点,上面一行依次减1,最后一直加到1,所以一共有(q-1)*(q-2)/2个点,注意会爆long long,要用快速乘解决。


#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stack>
#define ll unsigned long long
#define INF 0x3f3f3f3f
#define C(a) memset(a,0,sizeof a)
#define C_1(a) memset(a,-1,sizeof a)
#define C_i(a) memset(a,0x3f,sizeof a)
#define F(i,n) for(int i=0;i<n;i++)
#define F(n) for(int i=0;i<n;i++)
#define F_1(n) for(int i=n;i>0;i--)
#define S(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define SL(a) scanf("%I64d",&a)
#define SD(a) scanf("%lf",&a)
#define P(a) printf("%d\n",a)
#define PL(a) printf("%I64d\n",a)
#define PD(a)printf("%lf\n",a)
#define rush() int t;scanf("%d",&t);while(t--)
using namespace std;
ll qmul(ll a, ll b, ll p)
{
	ll ans = 0;
	while (b)
	{
		if (b & 1)ans = (ans + a) % p;
		a =(a*2)%p ;
		b >>= 1;
	}
	return ans;
}
int main()
{
	rush()
	{
		ll q, p,ans;
		cin >> q >> p;
		if ((q - 1) % 2)ans = qmul((q - 2) / 2, q - 1, p);
		else ans = qmul((q - 1) / 2, q - 2, p);
		cout << (ans%p+p)%p << endl;
	}
}



Problem Description
     Silen August does not like to talk with others.She like to find some interesting problems.

     Today she finds an interesting problem.She finds a segment  x+y=q .The segment intersect the axis and produce a delta.She links some line between  (0,0)  and the node on the segment whose coordinate are integers.

     Please calculate how many nodes are in the delta and not on the segments,output answer mod P.
 

Input
     First line has a number,T,means testcase number.

     Then,each line has two integers q,P.

    q  is a prime number,and  2≤q≤1018,1≤P≤1018,1≤T≤10.
 

Output
     Output 1 number to each testcase,answer mod P.
 

Sample Input
   
1 2 107
 

Sample Output
   
0
 

Source
 

Recommend
wange2014   |   We have carefully selected several similar problems for you:   5674  5673  5672  5671  5670 
Problem Description
     Silen August does not like to talk with others.She like to find some interesting problems.

     Today she finds an interesting problem.She finds a segment  x+y=q .The segment intersect the axis and produce a delta.She links some line between  (0,0)  and the node on the segment whose coordinate are integers.

     Please calculate how many nodes are in the delta and not on the segments,output answer mod P.
 

Input
     First line has a number,T,means testcase number.

     Then,each line has two integers q,P.

    q  is a prime number,and  2≤q≤1018,1≤P≤1018,1≤T≤10.
 

Output
     Output 1 number to each testcase,answer mod P.
 

Sample Input
   
1 2 107
 

Sample Output
   
0
 

Source
 

Recommend
wange2014   |   We have carefully selected several similar problems for you:   5674  5673  5672  5671  5670 
玩转Docker小游戏项目系列:Docker部署吃豆人经典小游戏 阅读详情

相关推荐

施耐德 Modicon M580 ePAC 项目实战:从硬件选型到 Control Expert V15 组态

本文详细解析了施耐德 Modicon M580 ePAC 在工业自动化项目中的实战应用,从硬件选型到 Control Expert V15 组态的全流程。重点介绍了水处理站控制系统的硬件配置、网络架构设计、软件安装授权及程序框架开发,帮助工程师高效实施中大型控制系统项目。

weixin_33701617的博客 334

hdu 5666 Segment【思维+快速积】

Segment    Accepts: 418    Submissions: 2020  Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) 问题描述 \ \ \ \    Rivendell非常神,喜欢研究奇怪的问题. \ \ \ \    今

mengxiang000000 1340

用Docker-Compose三节点部署生产级Doris集群:从配置文件到故障转移

本文详细介绍了如何使用Docker-Compose部署一个生产级的三节点Apache Doris集群。内容涵盖从核心架构理解、配置文件编写到集群初始化验证的全过程,并重点讲解了如何实现高可用、数据持久化、健康检查以及故障转移等生产级运维关键点,为中小团队提供了一种在容器化便利性与系统稳定性间取得平衡的可靠部署方案。

kkk56的博客 866

hdoj 5666 Segment ( 数学几何 +快速积)

Segment Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1756    Accepted Submission(s): 647 Problem Description     Silen August

R 689

机器学习项目(四)疫情期间网民情绪识别 (一)

疫情期间网民情绪识别 赛题背景 2019新型冠状病毒(2019-nCoV)感染的肺炎疫情发生对人们生活生产的方方面面产生了重要影响,并引发国内舆论的广泛关注,众多网民参与疫情相关话题的讨论。为了帮助政府掌握真实社会舆论情况,科学高效地做好防控宣传和舆情引导工作,本赛题针对疫情相关话题开展网民情绪识别的任务。 数据介绍 训练集 10万条 无标记样本90万条 测试集1万条 数据集依据与“新冠肺炎”相关...

qq_33357094的博客 8982

保姆级教程:用Jetson Orin Nano和ROS2 Humble搞定PIXhawk 4飞控通信(含配置文件详解)

本文提供了一份详细的Jetson Orin Nano与PIXhawk 4飞控通信配置指南,涵盖硬件连接、ROS2 Humble环境搭建、MAVROS2配置及通信调试全流程。通过实战案例和配置文件详解,帮助开发者快速实现无人机上位机与飞控的稳定通信,适用于无人机开发与自动化控制场景。

weixin_33670786的博客 487

java的segment_Segment(技巧 相乘转换成相加 + java)

Problem DescriptionSilen August does not like to talk with others.She like to find some interesting problems.Today she finds an interesting problem.She finds a segmentx+y=q.The segment intersect the ...

weixin_26876073的博客 748

基于Q-learning的无人机三维路径规划(含完整C++代码)

基于Q-learning的无人机三维路径规划(含完整C++代码)

weixin_54186646的博客 1万+

HDU - 5666 Segment (大数位运算)好题

HDU - 5666 Segment Time Limit: 1000MS   Memory Limit: 65536KB   64bit IO Format: %I64d & %I64u Submit Status Description Silen August does not like to talk with othe

yanghui07216的博客 1076

CCSP考后复盘:那些刷题时感觉良好,考场却发懵的题目到底长什么样?

本文深入分析了CCSP考试中常见的题目陷阱和解题策略,揭示了刷题与实战的差距。通过解析换装题、双胞胎选项和场景题等典型题型,帮助考生掌握拆题技巧和思维模式转变,提升应对CCSP考试的能力。

weixin_30485379的博客 443

别再自己写组件了!用uni-app的midButton属性5分钟搞定中间凸起TabBar(H5/小程序通用)

本文详细介绍了uni-app官方提供的midButton属性,帮助开发者5分钟内实现中间凸起的TabBar效果,无需编写繁琐的自定义组件代码。该方案兼容H5和微信小程序平台,配置简单且维护成本低,大幅提升开发效率和性能表现。

weixin_30431445的博客 353

HDU5666 Segment【大数】

Segment Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 2604 Accepted Submission(s): 986 Problem Description Silen August does not like to t...

海岛Blog 572

2026华为OD机考双机位C卷++ 双机位B卷 + 双机位A卷 + 2025C/B/A卷+ 往年真题 - 题库目录分值说明 + 考点说明+在线OJ

2025华为OD机考双机位C卷++ 双机位B卷 + 双机位A卷 + 2025C/B/A卷+ 往年真题 - 题库目录分值说明 + 考点说明+在线OJ

算法大师! 5万+

hdu 5666 Segment(快速乘)

Problem Description     Silen August does not like to talk with others.She like to find some interesting problems.     Today she finds an interesting problem.She finds a segment x+y=q.The

ZAQ的博客 614

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

HDU 5666 Segment (大数乘法取模)

Segment Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1765    Accepted Submission(s): 651 Problem Description     Silen August

Calm微笑 680

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

hdu 5666

题意:给出一个线段x+y= b,然后和0坐标组成的三角形内有多少整数点; 思路: 1 + …… + (n - 2);等差数列求和(n-2)*(n - 1)/2; 运用大数相乘取模; Segment Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

Everything can be done! 427

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

滑动Segment

Download 转载于:https://www.cnblogs.com/kiss007/archive/2013/05/08/3066938.html

weixin_34336292的博客 123

IDOC 标准Segment的修改一法 (后台定义表调整)

      有时候我们增强了一些标准字段, 比如加长等, 但对应的标准IDOC段并不会随之扩充. 按照SAP对IDoc段的管理, 也是只能新增字段而不能修改的, 此时只好想一些不太正常的手段来调整段类型了.      结构表: DD03L     段定义: EDSAPPL     可以直接修改后台这两个表来完成段的定义修改, 但要保证IDoc传递两个系统之间的段都要调整.     以上, 只是个思路,没有进行实际测试, 请大家慎用,当成没有办法的办法吧,呵呵.

Welcome to Garywang's IT BLOG. 4406

segment

$this->uri->segment(3);就是url上从index.php开始往后数,/划分

SY199505的博客 601

hdu5372(2015多校7)--Segment Game(树状数组)

题目链接:点击打开链接 题目大意:存在一个横轴,有n此操作,0代表在横轴上新增加一条边,1代表删除1条边,其中0 x代表在从x位置开始增加一条边,当第i次加边时,边的长度为i,1 x代表删除第x次加的边。问每当新加入一条边是,这条边能完整的包含几条边。 为什么当时没做这个题,,,已经泪奔,,, 问的是新加的那条边能覆盖多少条边,统计已加入的边的左端点大于或等于新边左端点的个数x,统计已加入的

随风的专栏 1031

hdu1558 Segment set

#include #include #define MAXN 1005 int father[MAXN],num[MAXN]; typedef struct node { double x,y; }point; struct edge { point p1; point p2; } seg[MAXN]; double Max(double x,double y) { return

不可不戒 733

【HDU 5666 Segment】+ 俄罗斯乘法

SegmentTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1771 Accepted Submission(s): 655Problem Description Silen August does not like t

楚江枫 599

BZOJ 3165: [Heoi2013]Segment

超哥线段树 #include<cstdio> #include<algorithm> using namespace std; const int lim=39989; const int Mod=1e9; int ansid,ANS[2000005],Max[100005],Maxid[100005]; double ans; struct node{...

weixin_34226706的博客 123

hdu 5666 Segment(BC规律题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5666 Segment Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1187    Accepted Submiss

若忆_star 746

shrink a segment

沾一篇来自metalink的好文 Oracle 10g Segment shrink =========================Mandatory=========Init.ora parameter 'C...

cri5768的博客 156

大模型高考评测:Qwen2-72B真实闭卷考试解析

大模型能力评估正从静态题库刷分转向真实场景化测试。高考作为人类通用智能的核心标尺,以其综合性、开放性与不可预测性,成为检验大模型语言理解、逻辑推理与文化表达能力的天然考场。其原理在于切断训练数据污染可能,依托真实阅卷标准实现人眼判分,技术价值在于揭示模型在语义连贯性、因果推演和文化语境理解上的深层断层。典型应用场景涵盖教育智能辅导、AI内容生成与知识服务系统的能力选型与Prompt优化。本文基于OpenCompass框架与Qwen2-72B实测数据,深入剖析语文‘文化失语症’、数学‘过程幻觉’与英语‘约束感

a2850363633的博客 435
上一篇: hdu 5665 Lucky(简单题)(bestcoder#80 1000)
下一篇: hdu 5667 Sequence(矩阵快速幂+快速幂+费马小定理)(bestcoder# 80 1002)
chat_c
博客等级 码龄12年 10粉丝 45原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值