GDUT_寒假训练题解报告_数论专题_个人题解报告——题目:B - Fedya and Maths

【物联网原理与应用】实验三:RFID低频卡实验——门禁系统 阅读详情

GDUT_寒假训练题解报告_数论专题_个人题解报告——题目:B - Fedya and Maths

题目:
Fedya studies in a gymnasium. Fedya’s maths hometask is to calculate the following expression:

(1n + 2n + 3n + 4n) mod 5
for given value of n. Fedya managed to complete the task. Can you? Note that given number n can be extremely large (e.g. it can exceed any integer type of your programming language).

Input
The single line contains a single integer n (0 ≤ n ≤ 10105). The number doesn’t contain any leading zeroes.

Output
Print the value of the expression without leading zeros.

Examples
Input
4
Output
4
Input
124356983594583453458888889
Output
0
这个一看,是费马小的基本运用:
a^(P-1)==1(mod P)
这个东西就能消去所有的(1,2,3,4)^4;
然后就是读入数据,取最后两个,为什么是最后两个呢,因为100是4的倍数,所以大于100的都没了,取N为最后两位,比如123444558,N就是58,然后N%=5就可以了,注意特判处理一下输入的n为个位数的情况:
完整代码:

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <climits>
#include <queue>
#include <stack>

using namespace std;
#define INF 0x3f3f3f3f
#define ULL unsigned long long

char n[100010];
int main()
{
	scanf("%s",n);
	int length=strlen(n);
	int N;
	if(length>1)N=(n[length-2]-'0')*10+n[length-1]-'0';
	else N=n[length-1]-'0';

	N%=4;
	int sum=0;
	int k;
	for(int time=1;time<5;time++)
	{
		k=1;
		for(int time1=0;time1<N;time1++)
		{
			k*=time;
		}
		sum+=k;
	}
	printf("%d\n",sum%5);

	return 0;
}

【图像拼接】论文精读:As-Rigid-As-Possible Shape Manipulation(ARAP) 文章目录前言1.摘要2.算法的总体流程总结 前言 图像变形算法 1.摘要 论文提出了一个二维图形互动系统。图形是建立在三角形网格上的,用户只需移动几个网格顶点(限制顶点),系统通过最小化每个三角形的误差计算网格剩余顶点(自由顶点)的位置。 算法分两步: 适当旋转每个三角形。 调整大小。 关键是使用二次度量误差将最小化问题转换成线性方程组,然后再解这个方程组。 刚性形状变形是很难的,论文的研究使其变得简单。 2.算法的总体流程 总的流程分三步: 将图形用三角形网格覆盖 选择三个点(限制顶点) 操纵限 阅读详情

相关推荐

PaddleOCR GPU部署:从环境配置到避坑实战指南

本文详细介绍了PaddleOCR GPU部署的全过程,从环境配置到避坑实战指南。通过分析常见的部署失败原因,提供硬件兼容性自查、软件环境精配方案以及路径配置的解决方案,帮助用户高效完成GPU加速的OCR任务部署,避免90%的常见错误。

weixin_30839881的博客 417

Codeforces--465B--Fedya and Maths

题目描述: Fedya studies in a gymnasium. Fedya’s maths hometask is to calculate the following expression: (1n + 2n + 3n + 4n) mod 5 for given value of n. Fedya managed to complete the task. Can you? Note t...

猩猩是个好程序员的博客 342

【智能体】零代码实战:Coze多智能体协作开发全流程解析

本文详细解析了Coze平台的多智能体协作开发全流程,从入门指南到实战技巧,帮助用户零代码构建高效AI团队。通过模块化设计和专业分工,多智能体系统能显著提升任务处理速度和准确率,适用于客服、内容创作、教育培训等多个场景。文章还提供了性能优化和常见问题解决方案,助力开发者快速掌握Multi-Agent技术。

weixin_29239279的博客 334

codeforces Round #260(div2) B解题报告

B. Fedya and Maths time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Fedya studies in a gymnasium. Fedya's mat

旅行者西瓜 744

半导体AMHS系统振动控制技术演进:从0.5G到超低振动的工艺革命

在半导体制造进入埃米级时代后,AMHS的振动控制能力将成为区分厂商技术等级的标尺。国内企业通过“弹性机械设计-混合主动控制-智能调度”的三重创新,正逐步突破0.2G阈值,支撑12英寸晶圆厂向3nm/2nm制程升级。未来,振动抑制不再仅是物流系统的性能参数,而是与光刻、刻蚀等核心工艺深度耦合的基础能力,这将重塑半导体设备产业的竞争格局。

m0_60674045的博客 1584

【IxNetwork】史上最全IxNetwork测试仪使用精讲(一),图文教程超赞超详细!!!

IXIA使用的是Server-client模式,Server端在测试仪表的主机上,在开机后会随着主机内的操作系统的启动而自动启动,一般情况下不需要人为的手工启动。因此在通常不需要为主机配置专用的显示器和键盘。client端包括两个测试软件: Ixia Explorer和ScriptMate。这两个软件一般安装在测试用计算机上,在仪表自带的主机中也有这两个软件。根据测试项目的不同来选择使用不同的软件。Ixia Explorer主要提供数据流的测试,针对设备的功能进行测试;

风云说通信 2054

寒假集训_专题四题解_B - Fedya and Maths

题目 Fedya studies in a gymnasium. Fedya’s maths hometask is to calculate the following expression: (1n + 2n + 3n + 4n) mod 5 for given value of n. Fedya managed to complete the task. Can you? Note that...

m0_46185124的博客 405

3分钟学会SQL中的断点去重技术,轻松搞定连续重复数据去重问题?

传感器采集的温度数据中,存在连续重复的值,需仅在数值变化时保留记录(例如:温度从 25°C 变为 26°C 时记录一次)。:判断逻辑,current_value!若当前温度与前一行的温度不同(或为第一条记录),则保留该行。的技术,常用于时间序列或状态日志中。:将连续相同值的记录合并,只保留断点处的记录。保留断点处的记录(即温度变化时的第一条)。原始数据表 sensor_data。最终仅保留值变化的断点记录。获取前一行的温度值。

石榴姐yyds 1019

B. Fedya and Maths

解题说明:此题通过找规律来做,首先分别

无知的我 1697

乐鑫科技 EchoEar 喵伴修改自定义唤醒词的方法 EchoEar喵伴、唤醒词修改、ESP32、AI萌宠、智能音箱、开发者指南

标签:乐鑫科技、EchoEar喵伴、唤醒词修改、ESP32、AI萌宠、智能音箱、开发者指南大家好,我是一名前端开发工程师,最近在玩乐鑫科技推出的时,发现它不仅萌趣十足,还能进行全双工语音交互、多模态识别,甚至能识别你的情绪和与你互动。EchoEar 喵伴是由乐鑫科技和火山引擎扣子大模型团队合作开发的,它使用乐鑫的芯片方案(ESP32 系列)+ 火山引擎扣子大模型,支持 WiFi 连接和本地处理,长记忆能力可以让它记住用户的偏好与习惯。

代码简单说 Vue、JAVA、PHP、Node.js 熟练运用,接口、架构、性能全搞定。 1880

深度学习工具包 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');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

CodeForces - 456B Fedya and Maths 打表找规律

GDUT 2020寒假训练 数论 B 原题链接 B - Fedya and Maths CodeForces - 456B Fedya and Maths 题目 Fedya studies in a gymnasium. Fedya’s maths hometask is to calculate the following expression: (1n + 2n + 3n + 4n)...

xcy2001的博客 403

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

模幂运算的循环节规律:从费马小定理到竞赛解题实战

模运算(Modular Arithmetic)是数论与计算机科学中的基础概念,它通过研究整数除以某个正整数的余数,将无限的数字系统映射到有限集合上。其核心原理在于同余关系的传递性与可加可乘性,这使得大规模计算得以简化。在工程实践中,模运算的价值尤为突出,特别是在密码学、散列函数和随机数生成等需要处理大整数且保证确定性的场景中。当涉及模幂运算(即计算 a^n mod m)时,直接计算往往因指数爆炸而不可行。此时,利用模幂的周期性规律——即余数序列会以固定长度循环——成为关键突破口。这一规律背后是费马小定理(当

weixin_30274627的博客 333

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

GDUT_寒假训练题解报告_专题I_L题 个人题解报告

GDUT_寒假训练题解报告_专题I_L题 个人题解报告 题目: You are given two integers a and b. You may perform any number of operations on them (possibly zero). During each operation you should choose any positive integer x and...

DevourPower的博客 880

GDUT_寒假训练题解报告_专题I_K题 个人题解报告:杭电题目Error Curves【裸三分】

GDUT_寒假训练题解报告_专题I_K题 个人题解报告 题目: Josephina is a clever girl and addicted to Machine Learning recently. She pays much attention to a method called Linear Discriminant Analysis, which has many interesti...

DevourPower的博客 702

GDUT_排位赛题解报告_第4场_E. Binary Tree

题目: In computer science, a binary tree is a rooted tree in which each node has at most two children. In this problem, let’s denote n as the number of nodes, l as the number of leaf nodes and h as the ...

DevourPower的博客 597

GDUT_寒假训练题解报告_专题I_A题 个人题解报告【尺取模板题目详解】【poj题目Subsequence】

GDUT_寒假训练题解报告_专题I_A、B、C、D题 个人题解报告 A题:尺取(模板题目 给出了一个N个正整数序列(10<N<1e5),每个正整数小于或等于10000,以及一个正整数S(S<1e8)。编写一个程序,以求序列的连续元素的子序列的最小长度,其和大于或等于S。 输入 第一行是测试用例的数量。对于每个测试用例,程序必须从第一行读取数字N和S,用间隔分隔。序列的数目在测试用...

DevourPower的博客 557

GDUT_排位赛题解报告_第3场_H. Photoshoot

题目: Farmer John is lining up his N cows (2≤N≤103), numbered 1…N, for a photoshoot. FJ initially planned for the i-th cow from the left to be the cow numbered ai, and wrote down the permutation a1,a2,…...

DevourPower的博客 525

GDUT_寒假训练题解报告_专题I_B、C、D题 个人题解报告

GDUT_寒假训练题解报告_专题I_B、C、D题 个人题解报告 B题 :dfs (我更喜欢叫它感染函数,因为之前写扫雷的时候教别人,不敢说dfs就说感染函数说顺口了。) 由于最近下雨,水在农民约翰的田里的各个地方汇集起来,用一个N×M(1<=N<=100;1<=M<=100)正方形表示。每一个正方形包含水(“W”)或旱地(“.”)。农场主约翰想弄清楚他的田里有多少池塘。...

DevourPower的博客 465

GDUT_排位赛题解报告_第5场_H. 完美排列

题目: ChenJr定义一个长度为n的完美排列为:对于一个任意的的i,都有a[i−1]>a[i]<a[i+1] 或者 a[i−1]<a[i]>a[i+1] 给你一个正整数n,你需要输出一个字典序最小的完美排列。 Input 一行输入一个正整数n (1≤n≤105)。 Output 输出n个整数,代表答案的排列。 Example inputCopy 1 outputCopy ...

DevourPower的博客 461

GDUT_寒假训练题解报告_数论专题_个人题解报告——题目:D - Beautiful Numbers (CodeForces - 300C)【逆元、组合数公式】

原题链接http://codeforces.com/problemset/problem/300/C 题目: Vitaly is a very weird man. He’s got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this int...

DevourPower的博客 444

GDUT_排位赛题解报告_第3场_D. Race

Bessie is running a race of length K (1≤K≤109) meters. She starts running at a speed of 0 meters per second. In a given second, she can either increase her speed by 1 meter per second, keep it unchang...

DevourPower的博客 435

GDUT_寒假训练题解报告_数论专题_个人题解报告——题目:E - Revenge of GCD【HDU - 5019】【数论(GCD,因数分解)】

原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=5019 题目: In mathematics, the greatest common divisor (gcd), also known as the greatest common factor (gcf), highest common factor (hcf), or greatest com...

DevourPower的博客 432

GDUT_排位赛题解报告_第4场_C. Defining Labels

题目: Microsoft Excel is a spreadsheet developed by Microsoft. It features calculation, graphing tools, pivot tables, and a macro programming language called Visual Basic for Applications. It has been a...

DevourPower的博客 422

GDUT_排位赛题解报告_第1场_B. MooBuzz

题目: Farmer John’s cows have recently become fans of playing a simple number game called “FizzBuzz”. The rules of the game are simple: standing in a circle, the cows sequentially count upward from one,...

DevourPower的博客 413

GDUT_排位赛题解报告_第3场_B.Loan Repayment

题目: Farmer John owes Bessie N gallons of milk (1≤N≤1012). He has to give her the milk within K days. However, he doesn’t want to give the milk away too quickly. On the other hand, he has to make forwa...

DevourPower的博客 408

GDUT_排位赛题解报告_第5场_A. 唯一排列

题目 ChenJr给你一个长度为n的排列p,你可以交换其中任意相邻的两个数。现在你需要用最小的交换次数使得这个排列变成升序的序列。现在ChenJr想知道,对于这个排列p,是否存在唯一的交换方式,使得这个排列变成升序的序列。 Input 第一行包含一个正整数T (1≤T≤5∗104),代表有T组样例。 对于每组样例,第一行包含一个n (1≤∑n≤105),代表排列的大小。 下一行包含n个正整数pi,...

DevourPower的博客 396
上一篇: GDUT_寒假训练题解报告_数论专题_个人题解报告——题目:A - k-rounding
下一篇: GDUT_寒假训练题解报告_图论专题_个人题解报告——题目:I - 还是畅通工程
DevourPower
博客等级 码龄7年 52粉丝 78原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值