• API
• FAQ
• Tools
• Archive
SHARE
TWEET # Untitled a guest Mar 22nd, 2018 135 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. #include <iostream>
2. #include <vector>
3. #include <algorithm>
4. #include <math.h>
5. #include <numeric>
6. #include <fstream>
7. #include <string.h>
8. #include <stdlib.h>
9.
10. using namespace std;
11.
12. /*
13.     Find the sum of the first thirty golden nuggets.
14. */
15.
16. long long f(int l) {
17.     int i;
18.     long long a, r, x, y;
19.
20.     //Init
21.     r = 0;
22.     a = 2; // First golden nugget
23.     x = -1;
24.     y = -1;
25.
26.     for(i = 0; i < l / 2; i++) {
27.         // Add golden nugget to answer
28.         r += a;
29.
30.         // Calculate next golden nugget
31.         a = (a + a) - x;
32.
33.         // Add golden nugget to answer
34.         r += a;
35.
36.         // Calculate next golden nugget
37.         a = (a * 4) - y;
38.
39.         // Update
40.         x = (y - x) / 2;
41.         y = 14 + (19 * x) - (y + y);
42.     }
43.
44.     return r;
45. }
46.
47. int main() {
48.     cout << "Result = " << f(30) << endl;
49.
50.     return 0;
51. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!

Top
{"ft_lang_label":"__label__en","ft_lang_prob":0.6825787,"math_prob":0.9573229,"size":1161,"snap":"2019-35-2019-39","text_gpt3_token_len":374,"char_repetition_ratio":0.14779602,"word_repetition_ratio":0.21317829,"special_character_ratio":0.4005168,"punctuation_ratio":0.16517857,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9812761,"pos_list":[0,1,2,3,4,5,6,7,8,9,10],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-09-21T18:55:53Z\",\"WARC-Record-ID\":\"<urn:uuid:45cbbac0-294b-4d41-a2fa-30954c078143>\",\"Content-Length\":\"22161\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:f9e6da27-8e78-46e4-918c-4ffe11c46f1a>\",\"WARC-Concurrent-To\":\"<urn:uuid:71e2eaa3-3010-4165-912c-957140e9fbd6>\",\"WARC-IP-Address\":\"104.22.3.84\",\"WARC-Target-URI\":\"https://pastebin.com/Ne5x7Vm5\",\"WARC-Payload-Digest\":\"sha1:Y7TID4QN6PJQW2UY2IK7YGEMFGRKULLE\",\"WARC-Block-Digest\":\"sha1:54I77TWMJRX2NJFOQR3KRDFE2IHVYI66\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-39/CC-MAIN-2019-39_segments_1568514574588.96_warc_CC-MAIN-20190921170434-20190921192434-00345.warc.gz\"}"}