$CJer{~}in{~}SJTU$ $\href{https://leopoldacc.github.io/Blogs/}{\text{My Blog}}$

1.4万

#include<iostream>
#include<cstring>

using namespace std;

const int N=110;
int a[N][N];

void init()
{
for(int i=1;i<101;i++)
{
for(int j=1;j<101;j++)
{
if(j<i)a[i][j] = a[j][i];
else a[i][j] = j-i+1;
}
}
}
int main()
{
int n;
init();

while(cin >> n,n)
{
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
cout << a[i][j] << ' ';
}
cout << endl;
}
cout << endl;
}
return 0;
}


#include<iostream>
#include<cstring>
#include<algorithm>

using namespace std;
int days[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
int res[8];
int main()
{
int n;
cin >> n;
int start=0;
int totday=0;
for(int i=1900;i<1900+n;i++)
{
for(int mon=0;mon<12;mon++)
{
res[(totday+13)%7]+=1;
int mon_day=days[mon];
if(mon==1)mon_day+=(i%4==0&&i%100!=0)||(i%400==0)?1:0;
totday+=mon_day;
}
}
for(int i=6;i<13;i++)cout << res[i%7] << ' ';
return 0;
}


#include<iostream>
#include<cstring>
#include<map>
using namespace std;
const int N=100010;
int n,m;
int a[N];
int main()
{
cin >> n >> m;
map<int,int> mp;
int res1=1e3,res2=1e3;
for(int i=0;i<n;i++)
{
cin >> a[i];
if(a[i]<=m)
{
if(mp.count(m-a[i]))
{
if(res1>m-a[i])
{
res1 = m-a[i];
res2 = a[i];
}
}
}
mp[a[i]]=i;
}
if(res1==1000)cout << "No Solution";
else cout << res1 << ' ' << res2;
return 0;
}


#include<iostream>
#include<cstring>
#include<string>
#include<map>
using namespace std;
const int N=110;

string s1,s2;

int main()
{
cin >> s1 >> s2;
map<char,char> mp{{'*','o'},{'o','*'}};
int res = 0;
for(int i=0;i<s1.size()-1;i++)
{
if(s1[i]!=s2[i])
{
res++;
s1[i] = mp[s1[i]];
s1[i+1] = mp[s1[i+1]];
}
else continue;
}
cout << res << endl;

return 0;
}


#include<iostream>
#include<cstring>
#include<algorithm>

using namespace std;

const int N=310;
struct student
{
int i,s,y;
bool operator<(const student &b)
{
if(s>b.s)return true;
else if(s<b.s)return false;
else
{
if(y>b.y)return true;
else if(y<b.y)return false;
else
{
if(i<b.i)return true;
else return false;
}
}
}
}stu[N];

int main()
{
int n;
cin >> n;
for(int i=0;i<n;i++)
{
int a,b,c;
cin >> a >> b >> c;
stu[i].i = i+1;
stu[i].s = a+b+c;
stu[i].y = a;
}
sort(stu,stu+n);
for(int i=0;i<5;i++)cout << stu[i].i << ' ' << stu[i].s << endl;
return 0;
}


## 从中午搞到晚上总共7个小时

(中间问了英伟达客服说是系统和驱动不匹配，但最后找到问题关键还是在于断网让系统不自动安装不适配的驱动版本)

• 0 下载DDU及最新版本驱动安装包-将之前的显卡驱动完全卸载(自己手动卸载会删不干净)

• 1 从设置-更新与安全-恢复-立即重新启动-高级选项-重新启动-启动时摁F4进入安全模式-启动DDU-卸载及重启

• 2 重启前断网(否则系统会自动安装之前不适配的驱动版本56.38),安装最新驱动

• 3 成功安装

1. 鲁大师安装的驱动能把你带到巨坑里
2. 思考问题产生的原因(联网时windows系统自动安装之前的版本)并试错(断网后再离线装)

#include<iostream>
#include<cstring>
#include<algorithm>

using namespace std;

const int N=100010;
struct A
{
int l,r;
bool operator<(const A &B)
{
return l<B.l;
}
}a[N];
int l,m;
int main()
{
cin >> l >> m;
for(int i=0;i<m;i++)cin >> a[i].l >> a[i].r;
sort(a,a+m);
int curr = -1,cnt = 0;
for(int i=0;i<m;i++)
{
if(a[i].r<=curr)continue;
cnt+=a[i].l<=curr?a[i].r-curr:a[i].r-a[i].l+1;
curr = max(curr,a[i].r);
}

cout << l+1-cnt;
return 0;
}


#include<iostream>
#include<cstring>

using namespace std;

const int N=100010;

int n,k;
int choc[N][2];

bool check(int x)
{
int sums = 0;
for(int i=0;i<n;i++)
{
sums+=(choc[i][0]/x) * (choc[i][1]/x);//乘号优先于除号 所以要括起来
if(sums>=k)return true;
}
return false;
}

int main()
{
cin >> n >> k;
int l=1,r=100000;
for(int i=0;i<n;i++)
{
cin >> choc[i][0] >> choc[i][1];
}
while(l<r)
{
int mid = (l+r+1)/2;
if(check(mid))l=mid;//数量够说明还可以变大
else r=mid-1;
}
cout << l;
return 0;
}


#include<iostream>
#include<cstring>

using namespace std;

const int N=1000010;
int a[N];
int n,m;

bool check(double x)
{
int sums = 0;
for(int i=0;i<n;i++)
{
// if(a[i]<x)return false;为啥不对呢,因为没有要求每条绳子都要剪
sums+=a[i]/x;
if(sums>=m)return true;
}
return false;
}

int main()
{
cin >> n >> m;
for(int i=0;i<n;i++)cin >> a[i];
double l=0,r=1e9;
for(int i=0;i<100;i++)
{
double mid = (l+r)/2;
if(check(mid))l=mid;//只要能剪出大于等于m个长度为mid的
else r=mid;
}
printf("%.2lf",l);
return 0;
}


#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>

using namespace std;

const int N=10010;

int B;
vector<char> map(21,'a');

string toB(int x)
{
string res = "";
while(x)
{
int tmp = x%B;
if(tmp<10)res+=to_string(tmp);
else res+=map[tmp];
x/=B;
}
reverse(res.begin(),res.end());
return res;
}

void init()
{
for(int i=10;i<21;i++)map[i] = 'A'+i-10;
}

int main()
{
init();
cin >> B;
for(int i=1;i<=300;i++)
{
vector<int> K;
int x = i*i;
while(x)
{
K.push_back(x%B);
x/=B;
}
int lens = K.size();
bool find = true;
for(int j=lens-1;j>=lens/2;j--)
{
if(K[j]!=K[lens-1-j])find = false;
}
if(find)cout << toB(i) << ' ' << toB(i*i) << endl;
}
return 0;
}