2017-07-10:考试(再次爆int,记住用long long)

这篇演讲鼓励听众通过经历不公平、背叛、孤独和失败来学会正义、忠诚、友情的重要性及理解生活的偶然性。它强调从不幸中汲取教训的价值。

Now the commencement speakers will typically also wish you good luck and extend good wishes to you. I will not do that, and I’ll tell you why.
From time to time in the years to come, I hope you will be treated unfairly, so that you will come to know the value of justice.
I hope that you will suffer betrayal because that will teach you the importance of loyalty.
Sorry to say, but I hope you will be lonely from time to time so that you don’t take friends for granted.
I wish you bad luck, again, from time to time so that you will be conscious of the role of chance in life and understand that your success is not completely deserved and that the failure of others is not completely deserved either.
And when you lose, as you will from time to time, I hope every now and then, your opponent will gloat over your failure. It is a way for you to understand the importance of sportsmanship.
I hope you’ll be ignored so you know the importance of listening to others,
and I hope you will have just enough pain to learn compassion.
Whether I wish these things or not, they’re going to happen.And whether you benefit from them or not will depend upon your ability to see the message in your misfortunes.


一题:快速幂用long long;


二题:用数组会爆内存,所以用vector;

用vector的好处:

在子函数内部定义vector是动态保存的,当再次返回此状态时,原来的vector内的数据仍然存在

#include<vector>;
vector<long long>vec;

vec.push_back(x);
tot++;

sort(vec.begin(),vec.end());
y=vec[tot-1];

三题:
1.曼哈顿距离:红色线为曼哈顿距离,绿色线为欧式距离(直线距离),蓝色与黄色为等价曼哈顿距离
红色线为曼哈顿距离,绿色线为欧式距离(直线距离),蓝色与黄色为等价曼哈顿距离

在Visual Studio 2008的C++中,如果你想要将包含日期和时间信息的字符串转换成无符号长整型(`unsigned long`),你可以手动解析字符串并将其各个部分组合起来。这里是一个简单的示例,假设你已经有了一个`char*`类型的字符串,比如`date_string`,格式为"yyyy-MM-dd HH:mm:ss": ```cpp #include <string> #include <iostream> // 将字符数组分割成单个数字 int parseInt(char* str, int start) { int num = 0; while (isdigit(*str)) { num = num * 10 + (*str - '0'); str++; } return num; } // 转换函数 unsigned long convertDateTimeToULong(const std::string& date_string) { // 提取年、月、日、小时、分钟和秒 int year = parseInt(date_string.c_str() + 4, 4); int month = parseInt(date_string.c_str() + 7, 2); int day = parseInt(date_string.c_str() + 9, 2); int hour = parseInt(date_string.c_str() + 12, 2); int minute = parseInt(date_string.c_str() + 15, 2); int second = parseInt(date_string.c_str() + 17, 2); // 根据规则计算总秒数 unsigned long total_seconds = static_cast<unsigned long>(year) * 31536000 + static_cast<unsigned long>(month) * 2592000 + static_cast<unsigned long>(day) * 86400 + static_cast<unsigned long>(hour) * 3600 + static_cast<unsigned long>(minute) * 60 + static_cast<unsigned long>(second); return total_seconds; } int main() { std::string date_string = "2023-01-01 12:34:56"; unsigned long timestamp = convertDateTimeToULong(date_string); std::cout << "Timestamp: " << timestamp << std::endl;
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值