头像

这可不是乱打的啊




离线:4小时前



include[HTML_REMOVED]

using namespace std;

int head[100001 * 2],edge[100001 * 2],Next[100001 * 2],ver[100001 * 2];
int vis[100001],dist[100001];
int n,p,q,d;
int t = 0;
int maxd = 0;

void add(int u,int v,int w) {
ver[t++] = v,edge[t] = w;
Next[t] = head[u],head[u] = t;
return ;
}

int BFS(int u) {
queue[HTML_REMOVED]Q;
while(!Q.empty()) Q.pop();
memset(vis,0,sizeof(vis));
memset(dist,0,sizeof(dist));
Q.push(u);
int x,max_num = 0;
while(!Q.empty()) {
x = Q.front();
Q.pop();
vis[x] = 1;
for(int i = head[x]; i ; i = Next[i]) {
int y = ver[i];
if(vis[y]) continue;
vis[y] = 1;
dist[y] = dist[x] + edge[i];
if(dist[y] > maxd ) {
maxd = dist[y];
max_num = y;
}
Q.push(y);
}
}
return max_num;
}

int main() {
cin>>n;
for(int i = 1; i < n; i ++) {
cin>>p>>q>>d;
add(p,q,d);
add(q,p,d);
}
int u = BFS(1);
int s = BFS(u);
cout<<maxd * 10 + maxd * (maxd + 1 ) / 2<<endl;
return 0;
}




include[HTML_REMOVED]

using namespace std;
int main()
{
int n, m, left = 0, right = 0;
cin>>n>>m;
for (int i = 1; i < n; i){
int x;
cin>>x;
if (abs(x) < abs(m) && x > 0) right
;
if (abs(x) > abs(m) && x < 0) left++;
}
if (m < 0 && right == 0|| m > 0 && left == 0) cout<<1<<endl;
else cout<<left + right + 1<<endl;
return 0;
}




include[HTML_REMOVED]

using namespace std;
int main(){
string a,b;
int jishu=0;
cin>>a>>b;
for(int i=0;i<a.length();i){
if(b[i]==a[i]);
else{
for(int j=i;j<=i+1;j
){
if(a[j]==’o’) a[j]=’*’;
else a[j]=’o’;
}
jishu++;
}
}
cout<<jishu;
return 0;
}




C++ 代码

```#include[HTML_REMOVED]
using namespace std;
int main(){
double a=1, b=1, c=1;
int n;
cin>>n;
if(n<25){
for(int i=1;i<n;i++){
c=a+b;
a=b;
b=c;
}
printf(“%.8f”,a/c);
}
else{
printf(“0.61803399”);
}
}




代码

include[HTML_REMOVED]

using namespace std;
int main(){
int n;
cin>>n;
cout<<n+(n-1)/2;
}




include[HTML_REMOVED]

using namespace std;
int main() {
int n, m, min = 1000, t = 1, count = 1;
cin >> n >> m;
if (n < min) min = n;
if (m < min) min = m;
vector < int > a;
a.push_back(1);

while (count < min) {
    if (t >= m &&  a[t - m] == 1) {
        a.push_back(1);
        count++;
    } else if (t >= n && a[t - n] == 1) {
        a.push_back(1);
        count++;
    } else {
        count = 0;
        a.push_back(0);
    }
    t++;
}

cout << a.size() - 1 - min << endl;

return 0;

}




include[HTML_REMOVED]

using namespace std;
int main() {
int t;
cin >> t;
vector < int > id;
while (cin >> t) {
id.push_back(t);
}
sort(id.begin(), id.end());
for (int i = 0; i < id.size(); i) {
if (id[i] + 2 == id[i + 1]) {
cout << id[i] + 1 << ” “;
}
}
for (int i = 0; i < id.size(); i
) {
if (id[i] == id[i + 1]) {
cout << id[i];
}
}
}