当前位置:网站首页>Ccf-csp 202112-3 boarding pass bar code 100 points
Ccf-csp 202112-3 boarding pass bar code 100 points
2022-06-09 02:43:00 【Confident little screw】
Original link :CCF-CSP 202112-3 Boarding pass bar code 
Reference blog :
CSP 202112-3 Boarding pass bar code
CSP 202112-3 Boarding pass bar code ( Detailed illustration )
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=929;
int main()
{
std::ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int w,s; cin>>w>>s;
string str; cin>>str;
vector<int> v;
for(int i=0;i<str.size();i++)
{
if(i==0)// At the beginning of coding , Encoder in uppercase mode .
{
// If the first character is lowercase
if(islower(str[i])) v.push_back(27);
else if(isdigit(str[i])) v.push_back(28);
}
if(isdigit(str[i]))
{
// Big / A lowercase letter -> Numbers
if(i-1>=0 && !isdigit(str[i-1])) v.push_back(28);
int tmp=str[i]-'0';
v.push_back(tmp);
}
else if(isupper(str[i]))
{
// Numbers -> Capitalization
if(i-1>=0 && isdigit(str[i-1])) v.push_back(28);
// A lowercase letter -> Capitalization
if(i-1>=0 && islower(str[i-1]))
{
v.push_back(28);
v.push_back(28);
}
int tmp=str[i]-'A';
v.push_back(tmp);
}
else if(islower(str[i]))
{
if(i-1>=0 && !islower(str[i-1])) v.push_back(27);
int tmp=str[i]-'a';
v.push_back(tmp);
}
}
if((int)v.size()%2!=0) v.push_back(29);
vector<int> d;
for(int i=0;i<v.size();i+=2)
{
int tmp=30*v[i]+v[i+1];
d.push_back(tmp);
}
if(s==-1)
{
int len=1+d.size();
if(len>w) w=(len/w+1)*w;
while(len<w)
{
d.push_back(900);
len++;
}
cout<<len<<endl;
for(auto tmp:d) cout<<tmp<<endl;
}
else
{
int k=pow(2,s+1);// Check the number of codewords
int ltmp=1+d.size()+k;
while(ltmp%w!=0)
{
d.push_back(900);
ltmp++;// Full length
}
int len=ltmp-k;// Number of all data codewords , Including length codewords 、 Valid data codeword 、 Fill codeword
// Calculation dx
vector<int> dx(len+k,0);// The length of itself len, multiply x Of k Power , So add k The length of
dx[0]=len;
for(int i=0;i<d.size();i++)
{
dx[i+1]=d[i];
dx[i+1]%=mod;
}
// Calculation dx
vector<int> gx(k+1,0);
gx[0]=-3; gx[1]=1;
for(int i=2;i<=k;i++)
{
vector<int> tmp;
tmp.assign(gx.begin(),gx.end());
gx[0]=0;
for(int j=1;j<=k;j++) gx[j]=tmp[j-1];
ll tt=1;
for(int j=0;j<i;j++) tt=(tt*3)%mod;
for(int j=0;j<=k;j++)
{
tmp[j]=(tmp[j]*tt)%mod;
tmp[j]*=-1;
gx[j]=(tmp[j]+gx[j])%mod;
}
}
reverse(gx.begin(),gx.end());
for(int i=0;i<dx.size()-k;i++)
{
int tt=dx[i];
for(int j=0;j<gx.size();j++)
{
dx[i+j]=(dx[i+j]-(tt*gx[j])%mod)%mod;
}
}
for(int i=dx.size()-k;i<dx.size();i++)
{
if(-dx[i]<0)
{
dx[i]%=mod;
d.push_back(mod-dx[i]);
}
else
{
dx[i]%=mod;
d.push_back(-dx[i]);
}
}
cout<<len<<endl;
for(auto tmp:d) cout<<tmp<<endl;
}
return 0;
}
边栏推荐
- Binding mode of QT overloaded signal slot function
- Period, duration calculation interval
- New textbook for self taught examination-p292
- Leetcode 974. And K divisible subarray prefix sum
- Basic method for missing data filling (2) -- random forest (missforest) filling
- 动态规划/n的k拆分 n的最大加数k拆分
- Leetcode 1248. Count "graceful subarray" prefix and
- Leetcode 454. Quad add II hash
- How does Jerry's SPI host configure the driver? [chapter]
- 4426 divisible substring (enumeration + number theory)
猜你喜欢

Tiflash source code reading (III) design and implementation analysis of tiflash deltatree storage engine - Part 1

Rcgi column - region of Overseas Social Market Research (including lottery)

Blue Bridge Cup_ Frog date_ Extended Euclid
![[network protocol] | [01] network byte order big end and small end](/img/9f/c69293aa8983161f4733a84389a311.png)
[network protocol] | [01] network byte order big end and small end

Docker installation redis

Ccp-csp 201912-5 magic number violence 25

Processes and threads

Ccf-csp 201903-2 24:00

Using redis in business code to achieve caching effect

Embracing out of hospital prescription drugs, Internet medicine should also "get rid of virtual reality"?
随机推荐
Ccf-csp 201412-3 call auction
【网络协议】| 【01】网络字节序大端、小端
Fight the high vision medical service of HKEx again, the gospel of short-sighted partners?
Exporter les connaissances pertinentes
Ccf-csp 201403-3 command line options
Using redis in business code to achieve caching effect
Go Technology Daily (2022 - 06 - 07) - go programer Development Efficiency God Summary
Leetcode 974. And K divisible subarray prefix sum
蓝桥杯_丢番图方程
Ccf-csp 201409-3 string matching
C# 基础篇
测试、预发布、生产环境测试时的侧重点是哪些?
Ccf-csp 201812-4 data center minimum spanning tree
Jericho's notes on SPI host configuration parameters: 【 chapter 】
Processes and threads
ClassNotFoundException vs NoClassDefFoundError
C#中的反射原理及应用
Ccf-csp 201909-4 recommended system 100 points
Calendar time operation
pkg-config --modversion opencvPackage opencv was not found in the pkg-config search path. Perhaps y