日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ACdream 1069 无耻的出题人 无聊写着玩的题

發布時間:2023/12/16 编程问答 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ACdream 1069 无耻的出题人 无聊写着玩的题 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

題目大意:

現在題目被加密了, 給出加密后的串

hjxh dwh v vxxpde,mmo ijzr yfcz hg pbzrxdvgqij rid stl mc zspm vfvuu vb uwu spmwzh.

一直前面4個詞是give you a number, 出題人說自己只會Fibonacci...

解密這一段文字然后寫程序


大致思路:

既然出題人說自己只會Fibonacci, 腦洞一下這個提議, 注意到前幾個字母: (h, g), (j, i), (x, v)..差距依次是1, 1, 2, 3, 5, 8....于是猜想字符差距是Fibonacci數, 以26為循環節即可

得到解密之后的題面是:give you a number,and your task is calculating the sum of each digit in the number

于是就是個無聊的求按位之和的題了, 注意n是long long 范圍當n取-2^63的時候轉正整數的long long會出錯就行了


代碼如下:

Result ?: ?Accepted ? ? Memory ?: ?1672 KB ? ? Time ?: ?0 ms

/* * this code is made by Gatevin * Problem: 1069 * Verdict: Accepted * Submission Date: 2015-09-13 22:10:16 * Time: 0MS * Memory: 1672KB */ /** Author: Gatevin* Created Time: 2015/9/12 12:12:47* File Name: Sakura_Chiyo.cpp*/ #include<iostream> #include<sstream> #include<fstream> #include<vector> #include<list> #include<deque> #include<queue> #include<stack> #include<map> #include<set> #include<bitset> #include<algorithm> #include<cstdio> #include<cstdlib> #include<cstring> #include<cctype> #include<cmath> #include<ctime> #include<iomanip> using namespace std; const double eps(1e-8); typedef long long lint; typedef unsigned long long ulint;/** hjxh dwh v vxxpde,mmo ijzr yfcz hg pbzrxdvgqij rid stl mc zspm vfvuu vb uwu spmwzh* give you a number* h - g = 1* j - i = 1* x - v = 2* h - e = 3* d - y = 26 + d - y = 5* w - o = 8* 猜想, 解密需要將所有字符加上Fibonacci數取模26得到, 前兩項是1 1*/int fib[100];int main() {//freopen("out.out", "w", stdout);fib[0] = fib[1] = 1;string s = "hjxh dwh v vxxpde,mmo ijzr yfcz hg pbzrxdvgqij rid stl mc zspm vfvuu vb uwu spmwzh";for(int i = 2, sz = s.length(); i < sz; i++)fib[i] = (fib[i - 1] + fib[i - 2]) % 26;int num = 0;for(int i = 0, sz = s.length(); i < sz; i++)if(s[i] != ' ' && s[i] != ',') s[i] = ((s[i] - 'a') - fib[num++] + 26) % 26 + 'a';//cout<<s<<endl;//s = "give you a number,and your task is calculating the sum of each digit in the number";lint n;while(scanf("%lld", &n) != EOF){ulint N;if(n < 0){N = (ulint)(-(n + 1)) + 1uLL;}else N = n;ulint ans = 0;while(N){ans += N % 10uLL;N /= 10uLL;}printf("%llu\n", ans);}return 0; }


總結

以上是生活随笔為你收集整理的ACdream 1069 无耻的出题人 无聊写着玩的题的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。