LA 7359 Sum Kind of problem (maths, water problem)

Source: Internet
Author: User

Test instructions: Given an n, the sum of the first n positive integers, positive and odd, and even.

Analysis: There is nothing to say, using the first n and the formula can be.

The code is as follows:

#pragma COMMENT (linker, "/stack:1024000000,1024000000") #include <cstdio> #include <string> #include < cstdlib> #include <cmath> #include <iostream> #include <cstring> #include <set> #include < queue> #include <algorithm> #include <vector> #include <map> #include <cctype> #include < Stack>using namespace Std;typedef Long Long ll;typedef pair<int, int> p;const int INF = 0x3f3f3f3f;const double I NF = 0x3f3f3f3f3f3f;const Double PI = ACOs ( -1.0); const double EPS = 1e-8;const int maxn = ten + 5;const int mod = 1e9 + 7;c Onst char *mark = "+-*"; const int dr[] = {-1, 0, 1, 0};const int dc[] = {0, 1, 0, -1};int N, m;inline bool is_in (int R, in T c) {return R >= 0 && r < n && C >= 0 && C < m;}    int main () {int T; cin >> T;        while (t--) {int kase;        scanf ("%d%d", &kase, &n);        ll ans1 = (LL) n (n+1)/2;        ll ans2 = (LL) n (2LL + 2ll*n)/2; LL ans3 = (LL) n * (2ll*n)/2;    printf ("%d%lld%lld%lld\n", Kase, Ans1, ANS3, ANS2); } return 0;}

  

LA 7359 Sum Kind of problem (maths, water problem)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.