#include<stdio.h>
long long l=1000000007;
long long pow(long long a,long long n)
{
int t=1;
while(n>0)
{
if(n&1)
t=t*a%l;
a=a*a%l;
n>>=1;
}
return t;
}
long long JS(long long n,long long y,long long x)
{
long long s,b,c,a;
if(n==1)
s=(x-y+1)%l;
else
{
a=pow(n,y)%l;
b=(a*(pow(n,x-y+1)-1)%l)%l;
c=pow(n-1,l-2)%l;
s=b*c%l;
}
return s;
}
int main()
{
long long t,s,a,b,c,m;
scanf("%lld",&t);
for(int i=1;i<=t;i++)
{
scanf("%lld",&m);
s=1;
for(int j=1;j<=m;j++)
{
scanf("%lld %lld %lld",&a,&b,&c);
s=s*JS(a,b,c)%l;
}
printf("Case #%d: %lld\n",i,s);
}
return 0;
}
相关推荐
Android各个版本存储权限适配
虽然 Android10 上面提出了外部存储分区的概念,不过之前的版本中,我们只要为应用添加了。1、AndroidManifest添加权限设置。3、拒绝权限时跳转详细设置页面。就可以像之前的方式一样访问手机的外部存储空间。2、请求所有文件管理权限。
超级和
题目描述 超级和是这样定义的: (1)对所有的正整数n,SuperSum(0,n)=n; (2)对所有正整数k,n,SuperSum(k,n)=SuperSum(k-1,1)+SuperSum(k-1,2)+...+SuperSum(k-1,n)。 现在给你k和n,请计算出SuperSum(k,n)。 输入输出格式 输入格式: 第一行,一个整数G,表示有G组数据; 第二至第G+1行...
隐藏在WAV音频里的秘密:用Python脚本从‘噪音’CTF题中提取Flag
本文详细解析了如何利用Python脚本从WAV音频文件中提取隐藏的Flag信息,特别针对CTF比赛中的音频隐写技术。通过分析WAV文件结构、编写Python解析脚本,并解决字节序处理和异常值等实际问题,帮助读者掌握从‘噪音’中解码Flag的技巧。
函数求值
题目: 定义超级和函数F如下: F(0, n) = n,对于所有的正整数n.. F(k, n) = F(k – 1, 1) + F(k – 1, 2) + … + F(k – 1, n),对于所有的正整数k和n. 请实现下面Solution类中计算F(k, n)的函数(1 class Solution { public: int F(int k, in
PyQtWebEngine安装避坑指南:快速解决ModuleNotFoundError
本文详细解析了PyQt5开发中常见的ModuleNotFoundError: No module named 'PyQt5.QtWebEngineWidgets'错误。核心原因是PyQt5 5.11版本后,网页引擎组件被独立为PyQtWebEngine包。文章对比了退回旧版本、独立安装及使用Conda等多种解决方案,并提供了针对Windows、macOS和Linux不同平台的实战安装指南与验证方法,帮助开发者快速解决依赖问题。
宏基因组分析|完整分析流程梳理
今天先从最基础的全流程框架说起,无论是刚接触的萌新,还是想查漏补缺的同行,都能找到有用的信息。
RSA 非对称加密 原理解析
加密算法是现在IT互联网,区块链的重要基石构建,在讲非对称加密算法之前,我们先了解下密码学中的对称加密。所谓的对称加密就是在加密和解密的过程中使用相同的密钥,即信息的发送方和接收方使用同一个密钥去加密和解密数据。 对称加密的优势是加解密速度快,但由于密钥是介于加解者之间共享使用,所以安全性就没有保障,一旦密钥泄露那加密的文件就相当于是明文。常见的对称加密算法有:DES、3DES、AES、...
销售预测的方法与模型(三)丨安全库存与再订货(补货)
较高的 Z 值对应较高的服务水平(例如,服务水平 99% 对应 Z 值 2.33),意味着企业希望更低的缺货风险,因此需要更高的安全库存。在再订货点的管理中,考虑到供应商交货的不确定性,通常需要结合安全库存,以防止在交货期间库存用尽。要对L开根号,根号L表示交货周期越长,企业需要的安全库存越多,因为在较长的供应期内,需求波动的累积效应更明显。举例:供应商的交期服从标准差为2件/天的正态分布,顾客需求为50件/天的正态分布,若要客户服务水平达到 90%,安全库存量应该是多少?下面介绍几种核心的模型与公式。
cesium.js入门(一)
webGIS ,基于Cesium.js的Demo,包含:初始化、加载geojson数据、加载glb模型
手把手教你学Simulink——基于AI融合与智能调度的场实例:强化学习在卫星资源分配中的应用
本文详细介绍了如何利用Simulink和强化学习技术实现智能卫星资源分配。文章首先分析了低轨卫星通信系统面临的动态资源调度挑战,提出采用强化学习(特别是PPO算法)的解决方案。接着逐步展示了完整的建模过程:从Simulink项目创建、卫星通信环境建模(用户业务、信道特性、资源池),到强化学习任务定义(状态空间、动作空间、奖励函数),再到PPO智能体的构建与训练。最后通过仿真验证,PPO智能体在系统吞吐量、公平性和阻塞率等关键指标上均优于传统方法。该方案为卫星通信系统的智能资源管理提供了可行方案,并支持进一步
基于最小二乘法(LS)和最小均方误差(MMSE)算法的导频信道估计
导频信道估计在无线通信系统中起着至关重要的作用,它用于估计无线信道的特性,以便在接收端进行正确的信号解调和解码。最小二乘法(LS)和最小均方误差(MMSE)是两种常用的导频信道估计算法,它们在估计精度和计算复杂度之间取得了良好的平衡。首先,我们提取当前的导频符号,然后将接收到的信号与导频符号相乘得到接收导频信号。最小二乘法是一种经典的导频信道估计算法,它通过最小化接收信号与预测信号之间的均方误差来估计信道。下面将详细介绍基于LS和MMSE算法的导频信道估计,并提供相应的MATLAB代码实现。
Python 内置函数深度解析:set()、setattr()、slice()、sorted()、staticmethod、str()、sum()、super()实用指南
1.2 实际应用:数据去重和成员检查 二、setattr():动态属性设置的"魔法师" 2.1 基础用法:动态设置对象属性 2.2 实际应用:动态配置系统 三、slice():切片操作的"导航器" 3.1 基础用法:创建切片对象 3.2 实际应用:自定义切片处理 四、sorted():数据排序的"整理师" 4.1 基础用法:排序可迭代对象 4.2 实际应用:复杂数据排序 五、@staticmethod:静态方法的"装饰器" 5.1 基础用法:创建静态方法 5.2 实际应用:工具类设计 六、
YOLOv12改进策略【Neck】| 使用CARAFE轻量级通用上采样算子
CARAFE内容感知的特征重新组合。
java中的super关键字(用supre操作被隐藏的成员变量和方法)
子类一旦隐藏了继承的成员变量,那么子类创建的对象就不再拥有该变量,该变量该归关键字super所拥有.同样,子类一旦隐藏了继承的方法,那么子类创建的对象级就不能调用被隐藏的方法,该方法的调用是super关键字负责.因此如果想在子类中使用被子类隐藏的成员变量或方法,就需要用super关键字。主类test_11_18。
贝叶斯统计 [韦来生编]
贝叶斯(Bayes)统计是近几十年来迅速发展起来的数理统计的一个重要分支。贝叶斯方法与经典统计方法的主要不同之处是进行统计推断时除了利用样本信息外,还要利用参数的先验信息,因此可以提高统计推断或统计决策的效果。它在经济、金融、生物、医学、自然科学和社会科学等许多领域具有广泛的应用。贝叶斯方法的研究已渗透到了统计学的几乎所有领域。作者在给中国科学技术大学概率论与数理统计专业本科生开设的“数理统计”课程中有一章专门讲授“贝叶斯方法和统计决策理论”,近十年来也给中国科学技术大学概率统计专业研究生开设过几次“贝叶斯分析”课。本书是在对过去讲稿的内容作了适当的增减和调整的基础上完成的。 本书共分六章。第1章是绪论,介绍了贝叶斯统计的若干基本概念,同时对必要的数理统计的基础知识有重点地作了回顾。第二章介绍了确定先验分布的若干可供选择的方法。第三章介绍了几类常见统计模型参数的后验分布的主要结果和计算方法。第四章和第五章分别介绍了“贝叶斯统计推断”和“贝叶斯统计决策”的内容。第六章介绍了贝叶斯统计计算的若干方法,包括蒙特卡洛方法和马尔可夫链蒙特卡洛(MCMC)方法以及相关统计软件的简介。本书的每一章附右大量的例题和习题,书末附有常用的几个表格和部分习题解答供读者查用。 大约可在54学时内讲授本书的第1章至第六章的主要内容,教师可根据学时需要选讲本书第1章至第六章的部分内容。书中标“*”号的章节可略去不讲,留给读者作为阅读材料。第六章例题中的R代码和部分例题的数据文件等可从作者个人主页下载。 作者在编写本书的过程中参考了J.O.Berger教授的《统计决策论及贝叶斯分析》和茆诗松教授编写的《贝叶斯统计》等书中的一些内容,以及《贝叶斯分析》一书中由张伟平博士编写的有关贝叶斯统计计算的一些内容。在此表示衷心感谢。 本书编写准备过程中,中国科学技术大学统计与金融系的几个研究生帮助完成了本书部分中文的录入和排版,作者对他们的辛勤工作表示真诚的感谢。高等教育出版社为本书的出版给予了大力支持。在此一并致谢。
Devexpress16.2.6破解工具
Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具
J - Super Sum UVA - 7720 (逆元与快速幂模板)
题目链接:https://vjudge.net/contest/174844#problem/J 题意: 给定N个 a,b,c 表示 每组有 a^b到 a^c, c-b+1个数,求每组取一个数相乘,所有可能的选取方法的乘积之和,对结果mod1000000007。 思路:先分析所有情况的乘积公式,很容易发现可以合并,然后问题就转变成了每组 a^b到 a^c的和的乘积。 求 a
深度学习工具包 DeepLearningToolbox
深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[](https://bitdeli.com/free "Bitdeli Badge")
最大子序列和(Max Sum ,Super Jumping! Jumping! Jumping! )
连续的子序列: Max Sum Given a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub...
大中型超市收银系统(可直接运行)
光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开
(LIS LCS 例题)Max Sum Advanced Fruits Super Jumping! Jumping! Jumping!
Given a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max sum in this sequence is 6 + (-1) + 5 + 4 = 14. Input The ...
2016 Asia Jakarta Regional Contest J - Super Sum UVALive - 7720 【快速幂+逆元】
J-Super Sum 题目大意就是给定N个三元组<a,b,c>求Σ(a1^k1*a2^k2*...*ai^ki*..an^kn)(bi<=ki<=ci) 唉。其实题目本身不难的,怪我不知道当时怎么想的。。。本来观察式子很容易能得出结论: 比如<5,2,3>,<2,1,4>,<3,2,2>这组: 5^2*2^1*3^2...
UVALive - 7720 The 2016 ACM-ICPC Asia Jakarta Regional Contest J - Super Sum
第二题。。 更惨的第四发才a。。 一开始这题居然把三个人都看懵了。 仔细一看发现就是求很多个等比数列的和然后相乘。。注意取模和逆元。。wa的很惨啊。 #include<bits/stdc++.h> #define UP(i,l,h) for(int i=l;i<h;i++) #define DOWN(i,h,l) for(int i=h-1;i>=l;i--) #define W(t) while(
java super关键字
子类用super操作被隐藏的成员变量和方法 Example5_7.java class Sum { int n; float f() { float sum=0; for(int i=1;i<=n;i++) sum=sum+i; return sum; } } ...
python内置函数 S
Python 解释器内置了很多函数和类型,任何时候都能使用。
(LIS LCS 例题)Max Sum Advanced Fruits Super Jumping! Jumping! Jumping!...
Given a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max sum in this sequence is 6 + (-1) + 5 + 4 =...
2024届美团第一次笔试第二题
2.小美的字符串匹配度小美有两个长度为n只包含小写字母的字符串s和t,小美定义“两个字符串的匹配度”为i∈[1,n]中si=ti的数量,例如"abacd"和"aabdd"的匹配度就是2。现在你可以进行最多一次以下操作:对于字符串t,选择两个索引i,j(1≤i
python杂记——内置函数(八)
python内置函数八
python新手一定要试试——终端计算器(带括号的加减乘除求幂混合运算)
从终端实现加、减、乘、除、求幂混合运算(带括号);数字与符号前后需空格(一个完整数字或符号内部不加空格,比如12、求幂符号);本身没有实际意义,分享解决问题的思路和转化为编程语言的技巧。
( UVALive 7720)J - Super Sum(逆元+扩展欧几里得/费马小定理)(补)
这道题我卡了一下午,原因是我之前写的数论题没用过逆元,之前写的一个(A/B)%mod的题,这个题当时就直接循环就水过去了,看了下别人写的 这是除法的模运算,用逆元求解的经典题型分析:这道题中关键在与求一个等比数列的和 S=a1*(q^n-1)/(q-1) 但是直接求的时候就会q^n溢出,直接取模,就会错。 S=(A/B)%mod 实质就是求这个式子,可以变成这样: S=(A%mod/(B
1849



被折叠的 条评论
为什么被折叠?



