L1-6 整除光棍(思维题)
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL N=100200,M=2020;
const double PI=3.141592;
int main()
{
cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
LL T=1;
//cin>>T;
while(T--)
{
LL n;
cin>>n;
LL sum=0,len=0;
while(sum<n)
{
sum=sum*10+1;
len++;
}//先计算出由111...组成的最小的大于等于n的数
while(1)
{
cout<<sum/n;//我们每次从头计算除法得到一个数值
if(sum%n==0)//求得余数看是不是0
{
cout<<" "<<len<<endl;//是的话直接输出长度
break;
}
sum%=n;//不是0的话把余数取出来
sum=sum*10+1;//尾巴上补一个1
len++;
}
}
return 0;
}
L1-7 装睡
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL N=100200,M=2020;
const double PI=3.141592;
int main()
{
cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
LL T=1;
//cin>>T;
while(T--)
{
LL n;
cin>>n;
for(int i=1;i<=n;i++)
{
string s;
cin>>s;
LL x,y;
cin>>x>>y;
if(x>=15&&x<=20&&y>=50&&y<=70) ;
else cout<<s<<endl;
}
}
return 0;
}
L1-8 矩阵A乘以B
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL N=100200,M=2020;
const double PI=3.141592;
LL a[M][M],b[M][M],c[M][M];
int main()
{
cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
LL T=1;
//cin>>T;
while(T--)
{
LL an,am;
cin>>an>>am;
for(int i=1;i<=an;i++)
{
for(int j=1;j<=am;j++)
{
cin>>a[i][j];
}
}
LL bn,bm;
cin>>bn>>bm;
for(int i=1;i<=bn;i++)
{
for(int j=1;j<=bm;j++)
{
cin>>b[i][j];
}
}
if(am!=bn) cout<<"Error: "<<am<<" != "<<bn;
else
{
cout<<an<<" "<<bm<<endl;
for(int i=1;i<=an;i++)
{
for(int j=1;j<=bm;j++)
{
LL ans=0;
for(int k=1;k<=am;k++)
{
//cout<<i<<" "<<j<<" "<<ans<<endl;
ans+=a[i][k]*b[k][j];
}
cout<<ans;
if(j!=bm) cout<<" ";
ans=0;
}
if(i!=an) cout<<endl;
}
}
}
return 0;
}