oj

【OJ】密码翻译

匿名 (未验证) 提交于 2019-12-03 00:14:01
题目内容: 在情报传递过程中,为了防止情报被截获,往往需要对情报用一定的方式加密,简单的加密算法虽然不足以完全避免情报被破译,但仍然能防止情报被轻易的识别。我们给出一种最简的的加密方法,对给定的一个字符串,把其中从a-y,A-Y的字母用其后继字母替代,把z和Z用a和A替代,则可得到一个简单的加密字符串。 输入格式: 第一行是字符串的数目n。 其余n行每行一个字符串。 输出格式: 输出每行字符串的加密字符串。 输入样例: 1 Hello ! How are you ! 输出样例: Ifmmp ! Ipx bsf zpv ! 1 #include <iostream> 2 #include <cstring> 3 using namespace std ; 4 int main (){ 5 int n ; 6 string str ; 7 cin >> n ; 8 cin . get (); 9 for ( int i = 0 ; i < n ; ++ i ){ 10 getline ( cin , str ); 11 for ( int j = 0 ; j < str . length (); ++ j ){ 12 if (( str [ j ] < 'z' && str [ j ] >= 'a' ) || str [ j ] < 'Z' && str [ j ] >= 'A' )

【OJ】大整数乘法

匿名 (未验证) 提交于 2019-12-03 00:11:01
思路:普通的每一位相乘,再相加。 利用string类的insert成员函数向后添加运算结果。注意字符运算和整型运算的区别。 1 #include <iostream> 2 using namespace std; 3 int main(){ 4 string a, b, c[200]; 5 int ans[401] = {0}; 6 int tmp, up = 0, k = 0, max_length; 7 cin >> a >> b; 8 for (int i = a.length() - 1; i >= 0; --i){ 9 c[k].insert(c[k].length(), k, '0'); 10 for (int j = b.length() - 1; j >= 0; --j){ 11 tmp = (a[i] - '0') * (b[j] - '0') + up; 12 up = tmp / 10; 13 tmp = tmp % 10; 14 c[k].insert(c[k].length(), 1, (char)(tmp + '0')); 15 } 16 if (up != 0){ 17 c[k].insert(c[k].length(), 1, (char)(up + '0')); 18 up = 0; 19 } 20 max_length = (max_length

【OJ】放苹果

匿名 (未验证) 提交于 2019-12-03 00:11:01
思路:递归。 1 #include <iostream> 2 using namespace std; 3 int func_apple(int x, int y){ 4 if (x == 1 || x == 0 || y == 1) 5 return 1; 6 if (x < y) 7 return func_apple(x, x); 8 return func_apple(x, y - 1) + func_apple(x - y, y); 9 } 10 int main(){ 11 int t, m, n; 12 cin >> t; 13 for (int i = 0; i < t; ++i){ 14 cin >> m >> n; 15 cout << func_apple(m, n) << endl; 16 } 17 return 0; 18 } 来源:博客园 作者: Victorique・De・Blois 链接:https://www.cnblogs.com/victorique-de-blois/p/11592409.html

湘潭大学oj循环1-5

匿名 (未验证) 提交于 2019-12-03 00:05:01
#include <stdio.h> #include <stdlib.h> int main() { int b,s,n; int a[101]; A:scanf("%d",&n); s=0; if(n!=0) { for(b=1;b<=n;b++) { scanf("%d",&a[b]); if(a[b]%2==0) s=s+a[b]; } printf("%d\n",s); goto A; } return 0; } 来源:博客园 作者: &delusion 链接:https://www.cnblogs.com/kyx599/p/11521258.html

Comet OJ - Contest #10 鱼跃龙门 exgcd+推导

匿名 (未验证) 提交于 2019-12-02 23:59:01
考试的时候推出来了,但是忘了 $exgcd$ 咋求,成功爆蛋~ 这里给出一个求最小正整数解的模板: ll solve ( ll A , ll B , ll C ) { ll x , y , g , b , ans ; gcd = exgcd ( A , B , x , y ); if ( C % gcd != 0 ) return - 1 ; x *= C / gcd , B /= gcd ; if ( B < 0 ) B =- B ; ans = x % B ; if ( ans <= 0 ) ans += B ; return ans ; } 大概就是这样. 说一下题: 可以将题目转化成求 $\frac{ans(ans+1)}{2}\mod n=0$ 的最小 $ans$. 将式子转化一下,即 $ans(ans+1)=2n\times y$,其中 $y$ 是个整数. 易得 $ans$ 与 $ans+1$ 是互质的,所以 $2n$ 中每一种不同的质因子只能贡献给 $ans,ans+1$ 中的一个. 而 $10^{12}$ 以内的数字最多只会有不到十多个本质不同的质因子,所以可以枚举子集. 考虑枚举出 $A$ 和 $B$,令 $A\times x=ans,B\times y=ans+1$. 则需要满足 $Ax-By=-1,gcd(x,y)=1$ 但其实我们发现 $gcd(x,y)=1

CentOS环境下搭建青岛大学OJ

匿名 (未验证) 提交于 2019-12-02 23:57:01
1.安装必要的依赖 sudo yum update sudo yum -y install epel-release sudo yum -y install python-pip sudo yum clean all sudo yum -y install python-pip pip install docker-compose sudo yum -y install vim sudo yum -y install curl sudo yum install -y git 2.安装 Docker (建议参见官方github文档) curl -sSL http://acs-public-mirror.oss-cn-hangzhou.aliyuncs.com/docker-engine/internet | sh - (找不到这个的镜像) curl -sSL https://get.daocloud.io/docker | sh sudo systemctl start docker sudo systemctl enable docker docker version 3.开始安装 (选择好安装路径运行命令) git clone -b 2.0 https://github.com/QingdaoU/OnlineJudgeDeploy.git && cd

CodeBlocks 配置

匿名 (未验证) 提交于 2019-12-02 23:55:01
Code::Blocks 17.12 时间:2019.6 下载网址 http://www.codeblocks.org/downloads/26 ,这里选择的是 mingw-setup 的版本 安装完成即可使用,自带了编译器。以下是一些笔者常用的配置。 View -> Perspectives -> Code::Blocks minimal F9 编译,出错按 F2 查看 Log 栏 Editor Settings Settings -> Editor -> General Settings TAB size in spaces 改为 2 官方地址 http://wiki.codeblocks.org/index.php?title=Syntax_highlighting_custom_colour_themes 配置目录在 ...\AppData\Roaming\CodeBlocks 下,备份 default.conf 文件 复制配置代码,保存在 default.conf 的配置文件中,打开 or 重启 CodeBlcoks。 Settings -> Editor -> Source formatter Bracket Style 选择 Google padding的设置中,设置在操作符旁添加空格 formatting 中,设置将 tab 转换成 space 不清楚的话,尽量与

Comet OJ - Contest #4 D求和 思维题

匿名 (未验证) 提交于 2019-12-02 23:51:01
#include <bits/stdc++.h> #define setIO(s) freopen(s".in","r",stdin) #define ll long long #define maxn 100000 using namespace std; int arr[30],brr[maxn]; ll calc(ll t) { int n=0,m=0; while(t) arr[++n]=t%10,t/=10; while(n>=1) { for(int i=2;i<=n;++i) brr[++m]=(arr[i]+arr[i-1])%10; while(brr[m]==0 && m>=2) --m; for(int i=1;i<=m;++i) arr[i]=brr[i]; n=m,m=0; } return arr[1]; } ll solve(ll k) { if(k<10) return k*(k+1)/2; ll re=(k/10)*45,t=calc((k/10)*10); int o=k%10; for(int i=0;i<=o;++i) re+=1ll*(t+i)%10; return re; } int main() { // setIO("input"); int T; scanf("%d",&T); while(T--) { ll l,r; scanf(

Comet OJ - Contest #5

匿名 (未验证) 提交于 2019-12-02 23:43:01
Comet OJ - Contest #5 总有一天,我会拿掉给 \(dyj\) 的小裙子的. A 显然 \(ans = min(cnt_1/3,cnt_4/2,cnt5)\) B 我们可以感性理解一下,最大的满足条件的 \(x\) 不会太大 因为当 \(x\) 越来越大时 \(f(x)\) 的增长速度比 \(x\) 的增长速度慢得多 其实可以证明,最大的满足的 \(x\) 不会超过 \(100\) 因为没有任何一个三位数的各位之和大于等于 \(50\) 所以我们就直接预处理 \(1-99\) 所有的合法的 暴力枚举即可 其实赛后题解说满足条件的 \(x\) 只有 \(17\) 和 \(18\) #include<cstdio> #include<cstring> #include<cctype> #include<iostream> #include<algorithm> using namespace std; //int a[N]; bool book[32131]; long long n; inline int work(int x){ int ans = 0; while(x){ ans += x % 10; x /= 10; } return ans; } int main(){ int T; for(int i = 2;i <= 100;++i){ if(work

Jarvis OJ (1)

匿名 (未验证) 提交于 2019-12-02 23:34:01
记录一下OJ平台的几道题顺便梳理一下知识点。 1.login 打开之后是一个密码框,查看源码也没什么发现,用bp抓包看一下 上面的hint处有一处sql查询 分析一下这句话 select * from `admin` where password='".md5($pass,true)."' MD5($pass,true) 参数1就是我们刚才看到的password,参数2 true 表示输出原始MD5转为字符串后的结果。即一个简单的字符串拼接。那么可以先从构造sql语句说起。绕过sql无非去构造一个 select * from xxx where pass='xxx' or 1=1 因此去找个字符串: ffifdyop MD5加密后 276f722736c95d99e921722cf9ed621c 转换字符串: 'or'6<xxx> 因此password=ffifdyop 2.神盾局的秘密 查看源码 一个乱码,img字段拿去解密, shield.jpg 看到这里可以想到文件包含,将index.php加密后放回去aW5kZXgucGhw index.php <?php require_once('shield.php'); $x = new Shield(); isset($_GET['class']) && $g = $_GET['class']; if (!empty($g)) {