目录
1.小乐乐求和
2.小乐乐与欧几里得
3.小乐乐与序列
1.小乐乐求和
#include
int main(){ int n = 0; long long sum = 0; int i = 0; scanf("%d", &n); for (i = 1; i <= n; i++) { sum += i; } printf("%lld", sum);//从题目中明确int类型是无法将这个结果存放的,所以要用long long int类型的变量进行存储 return 0;}
2.小乐乐与欧几里得
#includeint main(){long long n = 0;long long m = 0; scanf("%lld %lld",&n,&m);long long n2 = n;long long m2 = m;long long max = 0;long long min = 0;long long temp = 0;while (temp = n % m ){n = m;m = temp;}max = m;min = n2 * m2 / max;printf("%lld", max + min);return 0;}//这个题,也是必须使用long long int类型的变量来进行存储
3.小乐乐与序列
#includeint main(){ int n = 0; int arr[100001] = {0}; scanf("%d",&n); int tmp = 0; for(int i = 0;i
#include
#include
int main(){ int n = 0; int arr[100001] = {0}; scanf("%d",&n); int tmp = 0; for(int i = 0;i